Cleanup: visual ui / interface panels

This commit is contained in:
Charles J. Cliffe 2021-04-04 22:20:33 -04:00
parent 690896f65d
commit a0f1ccf68d
32 changed files with 203 additions and 250 deletions

View File

@ -27,7 +27,7 @@ GLPanel::GLPanel() : fillType(GLPANEL_FILL_SOLID), contentsVisible(true), visibl
} }
void GLPanel::genArrays() { void GLPanel::genArrays() {
float min = -1.0, mid = 0, max = 1.0; float gmin = -1.0, gmid = 0, gmax = 1.0;
if (fillType == GLPANEL_FILL_SOLID || fillType == GLPANEL_FILL_GRAD_X || fillType == GLPANEL_FILL_GRAD_Y) { if (fillType == GLPANEL_FILL_SOLID || fillType == GLPANEL_FILL_GRAD_X || fillType == GLPANEL_FILL_GRAD_Y) {
glPoints.reserve(2 * 4); glPoints.reserve(2 * 4);
@ -36,10 +36,10 @@ void GLPanel::genArrays() {
glColors.resize(4 * 4); glColors.resize(4 * 4);
float pts[2 * 4] = { float pts[2 * 4] = {
min, min, gmin, gmin,
min, max, gmin, gmax,
max, max, gmax, gmax,
max, min gmax, gmin
}; };
RGBA4f c[4]; RGBA4f c[4];
@ -73,15 +73,15 @@ void GLPanel::genArrays() {
if (fillType == GLPANEL_FILL_GRAD_BAR_X) { if (fillType == GLPANEL_FILL_GRAD_BAR_X) {
float pts[2 * 8] = { float pts[2 * 8] = {
min, min, gmin, gmin,
min, max, gmin, gmax,
mid, max, gmid, gmax,
mid, min, gmid, gmin,
mid, min, gmid, gmin,
mid, max, gmid, gmax,
max, max, gmax, gmax,
max, min gmax, gmin
}; };
glPoints.assign(pts, pts + (2 * 8)); glPoints.assign(pts, pts + (2 * 8));
@ -93,15 +93,15 @@ void GLPanel::genArrays() {
} else if (fillType == GLPANEL_FILL_GRAD_BAR_Y) { } else if (fillType == GLPANEL_FILL_GRAD_BAR_Y) {
float pts[2 * 8] = { float pts[2 * 8] = {
min, min, gmin, gmin,
min, mid, gmin, gmid,
max, mid, gmax, gmid,
max, min, gmax, gmin,
min, mid, gmin, gmid,
min, max, gmin, gmax,
max, max, gmax, gmax,
max, mid gmax, gmid
}; };
glPoints.assign(pts, pts + (2 * 8)); glPoints.assign(pts, pts + (2 * 8));
@ -154,11 +154,11 @@ float GLPanel::getHeight() {
return size[1]; return size[1];
} }
float GLPanel::getWidthPx() { float GLPanel::getWidthPx() const {
return pdim.x; return pdim.x;
} }
float GLPanel::getHeightPx() { float GLPanel::getHeightPx() const {
return pdim.y; return pdim.y;
} }
@ -179,8 +179,8 @@ void GLPanel::setCoordinateSystem(GLPanelCoordinateSystem coord_in) {
genArrays(); genArrays();
} }
bool GLPanel::hitTest(CubicVR::vec2 pos, CubicVR::vec2 &result) { bool GLPanel::hitTest(CubicVR::vec2 pos_in, CubicVR::vec2 &result) const {
CubicVR::vec4 hitPos = CubicVR::mat4::vec4_multiply(CubicVR::vec4(pos.x, pos.y, 0.0, 1.0), transformInverse); CubicVR::vec4 hitPos = CubicVR::mat4::vec4_multiply(CubicVR::vec4(pos_in.x, pos_in.y, 0.0, 1.0), transformInverse);
if (hitPos.x >= -1.0 && hitPos.x <= 1.0 && hitPos.y >= -1.0 && hitPos.y <= 1.0) { if (hitPos.x >= -1.0 && hitPos.x <= 1.0 && hitPos.y >= -1.0 && hitPos.y <= 1.0) {
result.x = hitPos.x; result.x = hitPos.x;
@ -197,12 +197,12 @@ void GLPanel::setFill(GLPanelFillType fill_mode) {
genArrays(); genArrays();
} }
void GLPanel::setFillColor(RGBA4f color1) { void GLPanel::setFillColor(const RGBA4f& color1) {
fill[0] = color1; fill[0] = color1;
genArrays(); genArrays();
} }
void GLPanel::setFillColor(RGBA4f color1, RGBA4f color2) { void GLPanel::setFillColor(const RGBA4f& color1, const RGBA4f& color2) {
fill[0] = color1; fill[0] = color1;
fill[1] = color2; fill[1] = color2;
genArrays(); genArrays();
@ -213,7 +213,7 @@ void GLPanel::setMarginPx(float marg) {
} }
void GLPanel::setBorderColor(RGBA4f clr) { void GLPanel::setBorderColor(const RGBA4f& clr) {
borderColor = clr; borderColor = clr;
} }
@ -234,7 +234,7 @@ void GLPanel::setBlend(GLuint src, GLuint dst) {
} }
void GLPanel::addChild(GLPanel *childPanel) { void GLPanel::addChild(GLPanel *childPanel) {
std::vector<GLPanel *>::iterator i = std::find(children.begin(), children.end(), childPanel); auto i = std::find(children.begin(), children.end(), childPanel);
if (i == children.end()) { if (i == children.end()) {
children.push_back(childPanel); children.push_back(childPanel);
@ -242,7 +242,7 @@ void GLPanel::addChild(GLPanel *childPanel) {
} }
void GLPanel::removeChild(GLPanel *childPanel) { void GLPanel::removeChild(GLPanel *childPanel) {
std::vector<GLPanel *>::iterator i = std::find(children.begin(), children.end(), childPanel); auto i = std::find(children.begin(), children.end(), childPanel);
if (i != children.end()) { if (i != children.end()) {
children.erase(i); children.erase(i);
@ -250,7 +250,7 @@ void GLPanel::removeChild(GLPanel *childPanel) {
} }
void GLPanel::drawChildren() { void GLPanel::drawChildren() {
if (children.size()) { if (!children.empty()) {
std::vector<GLPanel *>::iterator panel_i; std::vector<GLPanel *>::iterator panel_i;
for (panel_i = children.begin(); panel_i != children.end(); panel_i++) { for (panel_i = children.begin(); panel_i != children.end(); panel_i++) {
@ -306,7 +306,7 @@ void GLPanel::calcTransform(mat4 transform_in) {
} }
void GLPanel::draw() { void GLPanel::draw() {
float min = -1.0, max = 1.0; float gmin = -1.0, gmax = 1.0;
glLoadMatrixf(transform.to_ptr()); glLoadMatrixf(transform.to_ptr());
@ -330,32 +330,32 @@ void GLPanel::draw() {
if (borderPx.left) { if (borderPx.left) {
glLineWidth(borderPx.left); glLineWidth(borderPx.left);
glBegin(GL_LINES); glBegin(GL_LINES);
glVertex2f(min, min); glVertex2f(gmin, gmin);
glVertex2f(min, max); glVertex2f(gmin, gmax);
glEnd(); glEnd();
} }
if (borderPx.right) { if (borderPx.right) {
glLineWidth(borderPx.right); glLineWidth(borderPx.right);
glBegin(GL_LINES); glBegin(GL_LINES);
glVertex2f(max, min); glVertex2f(gmax, gmin);
glVertex2f(max, max); glVertex2f(gmax, gmax);
glEnd(); glEnd();
} }
if (borderPx.top) { if (borderPx.top) {
glLineWidth(borderPx.top); glLineWidth(borderPx.top);
glBegin(GL_LINES); glBegin(GL_LINES);
glVertex2f(min, min); glVertex2f(gmin, gmin);
glVertex2f(max, min); glVertex2f(gmax, gmin);
glEnd(); glEnd();
} }
if (borderPx.bottom) { if (borderPx.bottom) {
glLineWidth(borderPx.bottom); glLineWidth(borderPx.bottom);
glBegin(GL_LINES); glBegin(GL_LINES);
glVertex2f(min, max); glVertex2f(gmin, gmax);
glVertex2f(max, max); glVertex2f(gmax, gmax);
glEnd(); glEnd();
} }

View File

@ -63,7 +63,7 @@ public:
std::vector<GLPanel *> children; std::vector<GLPanel *> children;
GLPanel(); GLPanel();
virtual ~GLPanel() {}; virtual ~GLPanel() = default;;
void setPosition(float x, float y); void setPosition(float x, float y);
@ -71,18 +71,18 @@ public:
void setSize(float w, float h); void setSize(float w, float h);
float getWidth(); float getWidth();
float getHeight(); float getHeight();
float getWidthPx(); float getWidthPx() const;
float getHeightPx(); float getHeightPx() const;
void setCoordinateSystem(GLPanelCoordinateSystem coord); void setCoordinateSystem(GLPanelCoordinateSystem coord);
bool hitTest(CubicVR::vec2 pos, CubicVR::vec2 &result); bool hitTest(CubicVR::vec2 pos_in, CubicVR::vec2 &result) const;
void setFill(GLPanelFillType fill_mode); void setFill(GLPanelFillType fill_mode);
void setFillColor(RGBA4f color1); void setFillColor(const RGBA4f& color1);
void setFillColor(RGBA4f color1, RGBA4f color2); void setFillColor(const RGBA4f& color1, const RGBA4f& color2);
void setMarginPx(float marg); void setMarginPx(float marg);
void setBorderColor(RGBA4f clr); void setBorderColor(const RGBA4f& clr);
void setBorderPx(float bord); void setBorderPx(float bord);
void setBorderPx(float bordl, float bordr, float bordt, float bordb); void setBorderPx(float bordl, float bordr, float bordt, float bordb);
@ -107,7 +107,7 @@ private:
public: public:
GLTextPanel(); GLTextPanel();
void drawPanelContents(); void drawPanelContents() override;
void setText(std::string text, GLFont::Align hAlign = GLFont::GLFONT_ALIGN_CENTER, GLFont::Align vAlign = GLFont::GLFONT_ALIGN_CENTER , bool useNativeFont = false); void setText(std::string text, GLFont::Align hAlign = GLFont::GLFONT_ALIGN_CENTER, GLFont::Align vAlign = GLFont::GLFONT_ALIGN_CENTER , bool useNativeFont = false);
std::string getText(); std::string getText();
@ -119,5 +119,5 @@ public:
} }
void drawPanelContents(); void drawPanelContents() override;
}; };

View File

@ -15,7 +15,6 @@
#include "CubicSDR.h" #include "CubicSDR.h"
#include "CubicSDRDefs.h" #include "CubicSDRDefs.h"
#include "AppFrame.h"
#include <algorithm> #include <algorithm>
wxBEGIN_EVENT_TABLE(UITestCanvas, wxGLCanvas) EVT_PAINT(UITestCanvas::OnPaint) wxBEGIN_EVENT_TABLE(UITestCanvas, wxGLCanvas) EVT_PAINT(UITestCanvas::OnPaint)
@ -33,9 +32,7 @@ InteractiveCanvas(parent, dispAttrs) {
glContext = new UITestContext(this, &wxGetApp().GetContext(this), wxGetApp().GetContextAttributes()); glContext = new UITestContext(this, &wxGetApp().GetContext(this), wxGetApp().GetContextAttributes());
} }
UITestCanvas::~UITestCanvas() { UITestCanvas::~UITestCanvas() = default;
}
void UITestCanvas::OnPaint(wxPaintEvent& WXUNUSED(event)) { void UITestCanvas::OnPaint(wxPaintEvent& WXUNUSED(event)) {
// wxPaintDC dc(this); // wxPaintDC dc(this);
@ -61,7 +58,7 @@ void UITestCanvas::OnIdle(wxIdleEvent& /* event */) {
void UITestCanvas::OnMouseMoved(wxMouseEvent& event) { void UITestCanvas::OnMouseMoved(wxMouseEvent& event) {
InteractiveCanvas::OnMouseMoved(event); InteractiveCanvas::OnMouseMoved(event);
} }
void UITestCanvas::OnMouseDown(wxMouseEvent& event) { void UITestCanvas::OnMouseDown(wxMouseEvent& event) {

View File

@ -18,19 +18,19 @@
class UITestCanvas: public InteractiveCanvas { class UITestCanvas: public InteractiveCanvas {
public: public:
UITestCanvas(wxWindow *parent, const wxGLAttributes& dispAttrs); UITestCanvas(wxWindow *parent, const wxGLAttributes& dispAttrs);
~UITestCanvas(); ~UITestCanvas() override;
private: private:
void OnPaint(wxPaintEvent& event); void OnPaint(wxPaintEvent& event);
void OnIdle(wxIdleEvent &event); void OnIdle(wxIdleEvent &event);
void OnMouseMoved(wxMouseEvent& event); void OnMouseMoved(wxMouseEvent& event);
void OnMouseDown(wxMouseEvent& event); void OnMouseDown(wxMouseEvent& event);
void OnMouseWheelMoved(wxMouseEvent& event); void OnMouseWheelMoved(wxMouseEvent& event);
void OnMouseReleased(wxMouseEvent& event); void OnMouseReleased(wxMouseEvent& event);
void OnMouseEnterWindow(wxMouseEvent& event); void OnMouseEnterWindow(wxMouseEvent& event);
void OnMouseLeftWindow(wxMouseEvent& event); void OnMouseLeftWindow(wxMouseEvent& event);
UITestContext *glContext; UITestContext *glContext;
wxDECLARE_EVENT_TABLE(); wxDECLARE_EVENT_TABLE();

View File

@ -4,17 +4,15 @@
// SPDX-License-Identifier: GPL-2.0+ // SPDX-License-Identifier: GPL-2.0+
#include "ColorTheme.h" #include "ColorTheme.h"
#include "CubicSDR.h"
#include "CubicSDRDefs.h"
ThemeMgr ThemeMgr::mgr; ThemeMgr ThemeMgr::mgr;
void ThemeMgr::setTheme(int themeId) { void ThemeMgr::setTheme(int themeId_in) {
currentTheme = themes[themeId]; currentTheme = themes[themeId_in];
this->themeId = themeId; themeId = themeId_in;
} }
int ThemeMgr::getTheme() { int ThemeMgr::getTheme() const {
return themeId; return themeId;
} }

View File

@ -27,24 +27,24 @@ public:
r(r), g(g), b(b), a(a) { r(r), g(g), b(b), a(a) {
} }
RGBA4f() : RGBA4f(const RGBA4f &other) {
RGBA4f(0, 0, 0) {
}
~RGBA4f() {
}
RGBA4f & operator=(const RGBA4f &other) {
r = other.r; r = other.r;
g = other.g; g = other.g;
b = other.b; b = other.b;
a = other.a; a = other.a;
return *this;
} }
RGBA4f() :
RGBA4f(0, 0, 0) {
}
~RGBA4f() = default;
RGBA4f & operator=(const RGBA4f &other) = default;
RGBA4f operator*(float v) { return RGBA4f(r*v, g*v, b*v); } RGBA4f operator*(float v) const { return RGBA4f(r*v, g*v, b*v); }
operator wxColour() { explicit operator wxColour() const {
return wxColour( return wxColour(
(unsigned char) std::min((r * 255.0), 255.0), (unsigned char) std::min((r * 255.0), 255.0),
(unsigned char) std::min((g * 255.0), 255.0), (unsigned char) std::min((g * 255.0), 255.0),
@ -90,8 +90,8 @@ public:
~ThemeMgr(); ~ThemeMgr();
ColorTheme *currentTheme; ColorTheme *currentTheme;
std::map<int, ColorTheme *> themes; std::map<int, ColorTheme *> themes;
void setTheme(int themeId); void setTheme(int themeId_in);
int getTheme(); int getTheme() const;
int themeId; int themeId;
static ThemeMgr mgr; static ThemeMgr mgr;

View File

@ -14,8 +14,6 @@
#endif #endif
#include "CubicSDR.h" #include "CubicSDR.h"
#include "CubicSDRDefs.h"
#include "AppFrame.h"
#include <algorithm> #include <algorithm>
#include <cmath> #include <cmath>
@ -46,9 +44,7 @@ GainCanvas::GainCanvas(wxWindow *parent, const wxGLAttributes& dispAttrs) :
userGainAsChanged = false; userGainAsChanged = false;
} }
GainCanvas::~GainCanvas() { GainCanvas::~GainCanvas() = default;
}
void GainCanvas::OnPaint(wxPaintEvent& WXUNUSED(event)) { void GainCanvas::OnPaint(wxPaintEvent& WXUNUSED(event)) {
// wxPaintDC dc(this); // wxPaintDC dc(this);
@ -157,8 +153,6 @@ void GainCanvas::OnMouseDown(wxMouseEvent& event) {
void GainCanvas::OnMouseWheelMoved(wxMouseEvent& event) { void GainCanvas::OnMouseWheelMoved(wxMouseEvent& event) {
InteractiveCanvas::OnMouseWheelMoved(event); InteractiveCanvas::OnMouseWheelMoved(event);
CubicVR::vec2 hitResult;
CubicVR::vec2 mpos = mouseTracker.getGLXY(); CubicVR::vec2 mpos = mouseTracker.getGLXY();
for (auto gi : gainPanels) { for (auto gi : gainPanels) {
@ -217,9 +211,6 @@ void GainCanvas::updateGainUI() {
//to take into account a user gain change. Doesn't matter, //to take into account a user gain change. Doesn't matter,
//UpdateGainValues() takes cares of updating the true value realtime. //UpdateGainValues() takes cares of updating the true value realtime.
gains = devInfo->getGains(SOAPY_SDR_RX, 0); gains = devInfo->getGains(SOAPY_SDR_RX, 0);
SDRRangeMap::iterator gi;
numGains = gains.size(); numGains = gains.size();
float i = 0; float i = 0;
@ -232,15 +223,15 @@ void GainCanvas::updateGainUI() {
startPos = spacing/2.0; startPos = spacing/2.0;
barHeight = 1.0f; barHeight = 1.0f;
while (gainPanels.size()) { while (!gainPanels.empty()) {
MeterPanel *mDel = gainPanels.back(); MeterPanel *mDel = gainPanels.back();
gainPanels.pop_back(); gainPanels.pop_back();
bgPanel.removeChild(mDel); bgPanel.removeChild(mDel);
delete mDel; delete mDel;
} }
for (auto gi : gains) { for (const auto& gi : gains) {
MeterPanel *mPanel = new MeterPanel(gi.first, gi.second.minimum(), gi.second.maximum(), devConfig->getGain(gi.first,wxGetApp().getGain(gi.first))); auto *mPanel = new MeterPanel(gi.first, gi.second.minimum(), gi.second.maximum(), devConfig->getGain(gi.first,wxGetApp().getGain(gi.first)));
float midPos = -1.0+startPos+spacing*i; float midPos = -1.0+startPos+spacing*i;
mPanel->setPosition(midPos, 0); mPanel->setPosition(midPos, 0);
@ -271,14 +262,13 @@ bool GainCanvas::updateGainValues() {
DeviceConfig *devConfig = wxGetApp().getConfig()->getDevice(devInfo->getDeviceId()); DeviceConfig *devConfig = wxGetApp().getConfig()->getDevice(devInfo->getDeviceId());
gains = devInfo->getGains(SOAPY_SDR_RX, 0); gains = devInfo->getGains(SOAPY_SDR_RX, 0);
SDRRangeMap::iterator gi;
size_t numGainsToRefresh = std::min(gains.size(), gainPanels.size()); size_t numGainsToRefresh = std::min(gains.size(), gainPanels.size());
size_t panelIndex = 0; size_t panelIndex = 0;
//actually the order of gains iteration should be constant because map of string, //actually the order of gains iteration should be constant because map of string,
//and gainPanels were built in that order in updateGainUI() //and gainPanels were built in that order in updateGainUI()
for (auto gi : gains) { for (const auto& gi : gains) {
if (panelIndex >= numGainsToRefresh) { if (panelIndex >= numGainsToRefresh) {
break; break;

View File

@ -22,7 +22,7 @@
class GainCanvas: public InteractiveCanvas { class GainCanvas: public InteractiveCanvas {
public: public:
GainCanvas(wxWindow *parent, const wxGLAttributes& dispAttrs); GainCanvas(wxWindow *parent, const wxGLAttributes& dispAttrs);
~GainCanvas(); ~GainCanvas() override;
void setHelpTip(std::string tip); void setHelpTip(std::string tip);
void updateGainUI(); void updateGainUI();

View File

@ -32,7 +32,7 @@ void ImagePanel::render(wxDC& dc) {
double destw = destSize.GetWidth(); double destw = destSize.GetWidth();
double desth = destSize.GetHeight(); double desth = destSize.GetHeight();
double sf = 1.0, wf, hf; double sf, wf, hf;
wf = destw / imagew; wf = destw / imagew;
hf = desth / imageh; hf = desth / imageh;

View File

@ -14,9 +14,6 @@
#endif #endif
#include "CubicSDR.h" #include "CubicSDR.h"
#include "CubicSDRDefs.h"
#include "AppFrame.h"
#include <algorithm>
#include <wx/numformatter.h> #include <wx/numformatter.h>
@ -27,8 +24,7 @@ InteractiveCanvas::InteractiveCanvas(wxWindow *parent, const wxGLAttributes& dis
mouseTracker.setTarget(this); mouseTracker.setTarget(this);
} }
InteractiveCanvas::~InteractiveCanvas() { InteractiveCanvas::~InteractiveCanvas() = default;
}
void InteractiveCanvas::setView(long long center_freq_in, long long bandwidth_in) { void InteractiveCanvas::setView(long long center_freq_in, long long bandwidth_in) {
isView = true; isView = true;
@ -44,7 +40,7 @@ void InteractiveCanvas::disableView() {
lastBandwidth = 0; lastBandwidth = 0;
} }
bool InteractiveCanvas::getViewState() { bool InteractiveCanvas::getViewState() const {
return isView; return isView;
} }
@ -66,7 +62,7 @@ void InteractiveCanvas::setCenterFrequency(long long center_freq_in) {
centerFreq = center_freq_in; centerFreq = center_freq_in;
} }
long long InteractiveCanvas::getCenterFrequency() { long long InteractiveCanvas::getCenterFrequency() const {
if (isView) { if (isView) {
return centerFreq; return centerFreq;
} else { } else {
@ -78,7 +74,7 @@ void InteractiveCanvas::setBandwidth(long long bandwidth_in) {
bandwidth = bandwidth_in; bandwidth = bandwidth_in;
} }
long long InteractiveCanvas::getBandwidth() { long long InteractiveCanvas::getBandwidth() const {
if (isView) { if (isView) {
return bandwidth; return bandwidth;
} else { } else {
@ -90,15 +86,15 @@ MouseTracker *InteractiveCanvas::getMouseTracker() {
return &mouseTracker; return &mouseTracker;
} }
bool InteractiveCanvas::isAltDown() { bool InteractiveCanvas::isAltDown() const {
return altDown; return altDown;
} }
bool InteractiveCanvas::isCtrlDown() { bool InteractiveCanvas::isCtrlDown() const {
return ctrlDown; return ctrlDown;
} }
bool InteractiveCanvas::isShiftDown() { bool InteractiveCanvas::isShiftDown() const {
return shiftDown; return shiftDown;
} }

View File

@ -13,28 +13,28 @@
class InteractiveCanvas: public wxGLCanvas { class InteractiveCanvas: public wxGLCanvas {
public: public:
InteractiveCanvas(wxWindow *parent, const wxGLAttributes& dispAttrs); InteractiveCanvas(wxWindow *parent, const wxGLAttributes& dispAttrs);
virtual ~InteractiveCanvas(); ~InteractiveCanvas() override;
long long getFrequencyAt(float x); long long getFrequencyAt(float x);
long long getFrequencyAt(float x, long long iqCenterFreq, long long iqBandwidth); long long getFrequencyAt(float x, long long iqCenterFreq, long long iqBandwidth);
virtual void setView(long long center_freq_in, long long bandwidth_in); virtual void setView(long long center_freq_in, long long bandwidth_in);
virtual void disableView(); virtual void disableView();
bool getViewState(); bool getViewState() const;
void setCenterFrequency(long long center_freq_in); void setCenterFrequency(long long center_freq_in);
long long getCenterFrequency(); long long getCenterFrequency() const;
void setBandwidth(long long bandwidth_in); void setBandwidth(long long bandwidth_in);
long long getBandwidth(); long long getBandwidth() const;
MouseTracker *getMouseTracker(); MouseTracker *getMouseTracker();
bool isMouseInView(); bool isMouseInView();
bool isMouseDown(); bool isMouseDown();
bool isAltDown(); bool isAltDown() const;
bool isCtrlDown(); bool isCtrlDown() const;
bool isShiftDown(); bool isShiftDown() const;
protected: protected:
void OnKeyDown(wxKeyEvent& event); void OnKeyDown(wxKeyEvent& event);

View File

@ -36,15 +36,13 @@ MeterCanvas::MeterCanvas(wxWindow *parent, const wxGLAttributes& dispAttrs) :
glContext = new MeterContext(this, &wxGetApp().GetContext(this), wxGetApp().GetContextAttributes()); glContext = new MeterContext(this, &wxGetApp().GetContext(this), wxGetApp().GetContextAttributes());
} }
MeterCanvas::~MeterCanvas() { MeterCanvas::~MeterCanvas() = default;
}
void MeterCanvas::setLevel(float level_in) { void MeterCanvas::setLevel(float level_in) {
level = level_in; level = level_in;
Refresh(); Refresh();
} }
float MeterCanvas::getLevel() { float MeterCanvas::getLevel() const {
return level; return level;
} }
@ -68,7 +66,7 @@ void MeterCanvas::setInputValue(float slider_in) {
Refresh(); Refresh();
} }
bool MeterCanvas::inputChanged() { bool MeterCanvas::inputChanged() const {
return (inputValue != userInputValue); return (inputValue != userInputValue);
} }
@ -77,8 +75,8 @@ float MeterCanvas::getInputValue() {
return userInputValue; return userInputValue;
} }
void MeterCanvas::setShowUserInput(bool showUserInput) { void MeterCanvas::setShowUserInput(bool showUserInput_in) {
this->showUserInput = showUserInput; showUserInput = showUserInput_in;
} }
void MeterCanvas::OnPaint(wxPaintEvent& WXUNUSED(event)) { void MeterCanvas::OnPaint(wxPaintEvent& WXUNUSED(event)) {
@ -151,7 +149,7 @@ void MeterCanvas::OnMouseWheelMoved(wxMouseEvent& event) {
InteractiveCanvas::OnMouseWheelMoved(event); InteractiveCanvas::OnMouseWheelMoved(event);
float movement = 3.0 * (float)event.GetWheelRotation(); float movement = 3.0 * (float)event.GetWheelRotation();
float currentValue = 0; float currentValue;
if (showUserInput) { if (showUserInput) {
currentValue = userInputValue; currentValue = userInputValue;
} else { } else {

View File

@ -18,19 +18,19 @@
class MeterCanvas: public InteractiveCanvas { class MeterCanvas: public InteractiveCanvas {
public: public:
MeterCanvas(wxWindow *parent, const wxGLAttributes& dispAttrs); MeterCanvas(wxWindow *parent, const wxGLAttributes& dispAttrs);
~MeterCanvas(); ~MeterCanvas() override;
void setLevel(float level_in); void setLevel(float level_in);
float getLevel(); float getLevel() const;
void setMax(float max_in); void setMax(float max_in);
void setMin(float max_in); void setMin(float max_in);
void setUserInputValue(float slider_in); void setUserInputValue(float slider_in);
void setInputValue(float slider_in); void setInputValue(float slider_in);
bool inputChanged(); bool inputChanged() const;
float getInputValue(); float getInputValue();
void setShowUserInput(bool showUserInput); void setShowUserInput(bool showUserInput_in);
void setHelpTip(std::string tip); void setHelpTip(std::string tip);

View File

@ -6,8 +6,6 @@
#include "PrimaryGLContext.h" #include "PrimaryGLContext.h"
#include "Gradient.h" #include "Gradient.h"
#define NUM_WATERFALL_LINES 512
class MeterCanvas; class MeterCanvas;
class MeterContext: public PrimaryGLContext { class MeterContext: public PrimaryGLContext {

View File

@ -35,9 +35,7 @@ InteractiveCanvas(parent, dispAttrs), numChoices(0), currentSelection(-1), toggl
highlightColor = RGBA4f(1.0,1.0,1.0,1.0); highlightColor = RGBA4f(1.0,1.0,1.0,1.0);
} }
ModeSelectorCanvas::~ModeSelectorCanvas() { ModeSelectorCanvas::~ModeSelectorCanvas() = default;
}
int ModeSelectorCanvas::getHoveredSelection() { int ModeSelectorCanvas::getHoveredSelection() {
if (!mouseTracker.mouseInView()) { if (!mouseTracker.mouseInView()) {
@ -163,7 +161,7 @@ void ModeSelectorCanvas::addChoice(std::string label) {
numChoices = selections.size(); numChoices = selections.size();
} }
void ModeSelectorCanvas::setSelection(std::string label) { void ModeSelectorCanvas::setSelection(const std::string& label) {
for (int i = 0; i < numChoices; i++) { for (int i = 0; i < numChoices; i++) {
if (selections[i].label == label) { if (selections[i].label == label) {
currentSelection = i; currentSelection = i;
@ -201,11 +199,11 @@ int ModeSelectorCanvas::getSelection() {
return selections[currentSelection].value; return selections[currentSelection].value;
} }
void ModeSelectorCanvas::setToggleMode(bool toggleMode) { void ModeSelectorCanvas::setToggleMode(bool toggleMode_in) {
this->toggleMode = toggleMode; toggleMode = toggleMode_in;
} }
bool ModeSelectorCanvas::modeChanged() { bool ModeSelectorCanvas::modeChanged() const {
return inputChanged; return inputChanged;
} }
@ -213,12 +211,12 @@ void ModeSelectorCanvas::clearModeChanged() {
inputChanged = false; inputChanged = false;
} }
void ModeSelectorCanvas::setPadding(float padX, float padY) { void ModeSelectorCanvas::setPadding(float padX_in, float padY_in) {
this->padX = padX; padX = padX_in;
this->padY = padY; padY = padY_in;
} }
void ModeSelectorCanvas::setHighlightColor(RGBA4f hc) { void ModeSelectorCanvas::setHighlightColor(const RGBA4f& hc) {
this->highlightColor = hc; highlightColor = hc;
this->highlightOverride = true; highlightOverride = true;
} }

View File

@ -28,25 +28,25 @@ public:
class ModeSelectorCanvas: public InteractiveCanvas { class ModeSelectorCanvas: public InteractiveCanvas {
public: public:
ModeSelectorCanvas(wxWindow *parent, const wxGLAttributes& dispAttrs); ModeSelectorCanvas(wxWindow *parent, const wxGLAttributes& dispAttrs);
~ModeSelectorCanvas(); ~ModeSelectorCanvas() override;
int getHoveredSelection(); int getHoveredSelection();
void setHelpTip(std::string tip); void setHelpTip(std::string tip);
void addChoice(int value, std::string label); void addChoice(int value, std::string label);
void addChoice(std::string label); void addChoice(std::string label);
void setSelection(std::string label); void setSelection(const std::string& label);
std::string getSelectionLabel(); std::string getSelectionLabel();
void setSelection(int value); void setSelection(int value);
int getSelection(); int getSelection();
void setToggleMode(bool toggleMode); void setToggleMode(bool toggleMode_in);
bool modeChanged(); bool modeChanged() const;
void clearModeChanged(); void clearModeChanged();
void setPadding(float padX, float padY); void setPadding(float padX_in, float padY_in);
void setHighlightColor(RGBA4f hc); void setHighlightColor(const RGBA4f& hc);
private: private:
void setNumChoices(int numChoices_in); void setNumChoices(int numChoices_in);

View File

@ -25,7 +25,7 @@ void ModeSelectorContext::DrawBegin() {
glDisable(GL_TEXTURE_2D); glDisable(GL_TEXTURE_2D);
} }
void ModeSelectorContext::DrawSelector(std::string label, int c, int cMax, bool on, float r, float g, float b, float a, float px, float py) { void ModeSelectorContext::DrawSelector(const std::string& label, int c, int cMax, bool on, float r, float g, float b, float a, float px, float py) {
GLint vp[4]; GLint vp[4];
glGetIntegerv( GL_VIEWPORT, vp); glGetIntegerv( GL_VIEWPORT, vp);

View File

@ -6,8 +6,6 @@
#include "PrimaryGLContext.h" #include "PrimaryGLContext.h"
#include "Gradient.h" #include "Gradient.h"
#define NUM_WATERFALL_LINES 512
class ModeSelectorCanvas; class ModeSelectorCanvas;
class ModeSelectorContext: public PrimaryGLContext { class ModeSelectorContext: public PrimaryGLContext {
@ -15,6 +13,6 @@ public:
ModeSelectorContext(ModeSelectorCanvas *canvas, wxGLContext *sharedContext, wxGLContextAttrs *ctxAttrs); ModeSelectorContext(ModeSelectorCanvas *canvas, wxGLContext *sharedContext, wxGLContextAttrs *ctxAttrs);
void DrawBegin(); void DrawBegin();
void DrawSelector(std::string label, int c, int cMax, bool on, float r, float g, float b, float a, float padx, float pady); void DrawSelector(const std::string& label, int c, int cMax, bool on, float r, float g, float b, float a, float padx, float pady);
void DrawEnd(); void DrawEnd();
}; };

View File

@ -14,13 +14,10 @@
#endif #endif
#include "CubicSDR.h" #include "CubicSDR.h"
#include "CubicSDRDefs.h"
#include "AppFrame.h"
#include <algorithm>
wxString PrimaryGLContext::glGetwxString(GLenum name) { wxString PrimaryGLContext::glGetwxString(GLenum name) {
const GLubyte *v = glGetString(name); const GLubyte *v = glGetString(name);
if (v == 0) { if (v == nullptr) {
// The error is not important. It is GL_INVALID_ENUM. // The error is not important. It is GL_INVALID_ENUM.
// We just want to clear the error stack. // We just want to clear the error stack.
glGetError(); glGetError();
@ -65,7 +62,7 @@ PrimaryGLContext::PrimaryGLContext(wxGLCanvas *canvas, wxGLContext *sharedContex
//#endif //#endif
} }
void PrimaryGLContext::DrawDemodInfo(DemodulatorInstancePtr demod, RGBA4f color, long long center_freq, long long srate, bool centerline) { void PrimaryGLContext::DrawDemodInfo(const DemodulatorInstancePtr& demod, const RGBA4f& color, long long center_freq, long long srate, bool centerline) {
if (!demod) { if (!demod) {
return; return;
} }
@ -203,7 +200,7 @@ void PrimaryGLContext::DrawDemodInfo(DemodulatorInstancePtr demod, RGBA4f color,
} }
void PrimaryGLContext::DrawFreqBwInfo(long long freq, int bw, RGBA4f color, long long center_freq, long long srate, bool stack, bool centerline) { void PrimaryGLContext::DrawFreqBwInfo(long long freq, int bw, const RGBA4f& color, long long center_freq, long long srate, bool stack, bool centerline) {
if (!srate) { if (!srate) {
srate = wxGetApp().getSampleRate(); srate = wxGetApp().getSampleRate();
} }
@ -310,7 +307,7 @@ void PrimaryGLContext::DrawFreqBwInfo(long long freq, int bw, RGBA4f color, long
glDisable(GL_BLEND); glDisable(GL_BLEND);
} }
void PrimaryGLContext::DrawDemod(DemodulatorInstancePtr demod, RGBA4f color, long long center_freq, long long srate) { void PrimaryGLContext::DrawDemod(const DemodulatorInstancePtr& demod, const RGBA4f& color, long long center_freq, long long srate) {
if (!demod) { if (!demod) {
return; return;
} }
@ -431,7 +428,7 @@ void PrimaryGLContext::drawSingleDemodLabel(const std::wstring& demodStr, float
refDrawingFont.drawString(demodStr, 2.0 * (uxPos - 0.5), -1.0 + hPos, demodAlign, GLFont::GLFONT_ALIGN_CENTER, 0, 0, true); refDrawingFont.drawString(demodStr, 2.0 * (uxPos - 0.5), -1.0 + hPos, demodAlign, GLFont::GLFONT_ALIGN_CENTER, 0, 0, true);
} }
void PrimaryGLContext::DrawFreqSelector(float uxPos, RGBA4f color, float w, long long /* center_freq */, long long srate) { void PrimaryGLContext::DrawFreqSelector(float uxPos, const RGBA4f& color, float w, long long /* center_freq */, long long srate) {
DemodulatorInstancePtr demod = wxGetApp().getDemodMgr().getCurrentModem(); DemodulatorInstancePtr demod = wxGetApp().getDemodMgr().getCurrentModem();
@ -483,7 +480,7 @@ void PrimaryGLContext::DrawFreqSelector(float uxPos, RGBA4f color, float w, long
} }
void PrimaryGLContext::DrawRangeSelector(float uxPos1, float uxPos2, RGBA4f color) { void PrimaryGLContext::DrawRangeSelector(float uxPos1, float uxPos2, const RGBA4f& color) {
if (uxPos2 < uxPos1) { if (uxPos2 < uxPos1) {
float temp = uxPos2; float temp = uxPos2;
uxPos2=uxPos1; uxPos2=uxPos1;
@ -531,6 +528,6 @@ void PrimaryGLContext::EndDraw() {
// CheckGLError(); // CheckGLError();
} }
void PrimaryGLContext::setHoverAlpha(float hoverAlpha) { void PrimaryGLContext::setHoverAlpha(float hoverAlpha_in) {
this->hoverAlpha = hoverAlpha; hoverAlpha = hoverAlpha_in;
} }

View File

@ -24,14 +24,14 @@ public:
void BeginDraw(float r, float g, float b); void BeginDraw(float r, float g, float b);
void EndDraw(); void EndDraw();
void DrawFreqSelector(float uxPos, RGBA4f color, float w = 0, long long center_freq = -1, long long srate = 0); void DrawFreqSelector(float uxPos, const RGBA4f& color, float w = 0, long long center_freq = -1, long long srate = 0);
void DrawRangeSelector(float uxPos1, float uxPos2, RGBA4f color); void DrawRangeSelector(float uxPos1, float uxPos2, const RGBA4f& color);
void DrawDemod(DemodulatorInstancePtr demod, RGBA4f color, long long center_freq = -1, long long srate = 0); void DrawDemod(const DemodulatorInstancePtr& demod, const RGBA4f& color, long long center_freq = -1, long long srate = 0);
void DrawDemodInfo(DemodulatorInstancePtr demod, RGBA4f color, long long center_freq = -1, long long srate = 0, bool centerline = false); void DrawDemodInfo(const DemodulatorInstancePtr& demod, const RGBA4f& color, long long center_freq = -1, long long srate = 0, bool centerline = false);
void DrawFreqBwInfo(long long freq, int bw, RGBA4f color, long long center_freq = - 1, long long srate = 0, bool stack = false, bool centerline = false); void DrawFreqBwInfo(long long freq, int bw, const RGBA4f& color, long long center_freq = - 1, long long srate = 0, bool stack = false, bool centerline = false);
void setHoverAlpha(float hoverAlpha); void setHoverAlpha(float hoverAlpha_in);
private: private:
float hoverAlpha; float hoverAlpha;

View File

@ -14,8 +14,6 @@
#endif #endif
#include "CubicSDR.h" #include "CubicSDR.h"
#include "CubicSDRDefs.h"
#include "AppFrame.h"
#include <algorithm> #include <algorithm>
#include <cmath> #include <cmath>
@ -31,7 +29,7 @@ EVT_LEAVE_WINDOW(ScopeCanvas::OnMouseLeftWindow)
EVT_ENTER_WINDOW(ScopeCanvas::OnMouseEnterWindow) EVT_ENTER_WINDOW(ScopeCanvas::OnMouseEnterWindow)
wxEND_EVENT_TABLE() wxEND_EVENT_TABLE()
ScopeCanvas::ScopeCanvas(wxWindow *parent, const wxGLAttributes& dispAttrs) : InteractiveCanvas(parent, dispAttrs), ppmMode(false), ctr(0), ctrTarget(0), dragAccel(0), helpTip("") { ScopeCanvas::ScopeCanvas(wxWindow *parent, const wxGLAttributes& dispAttrs) : InteractiveCanvas(parent, dispAttrs), ppmMode(false), ctr(0), ctrTarget(0), dragAccel(0) {
glContext = new ScopeContext(this, &wxGetApp().GetContext(this), wxGetApp().GetContextAttributes()); glContext = new ScopeContext(this, &wxGetApp().GetContext(this), wxGetApp().GetContextAttributes());
inputData->set_max_num_items(2); inputData->set_max_num_items(2);
@ -51,9 +49,7 @@ ScopeCanvas::ScopeCanvas(wxWindow *parent, const wxGLAttributes& dispAttrs) : In
spectrumPanel.setUseDBOffset(false); spectrumPanel.setUseDBOffset(false);
} }
ScopeCanvas::~ScopeCanvas() { ScopeCanvas::~ScopeCanvas() = default;
}
bool ScopeCanvas::scopeVisible() { bool ScopeCanvas::scopeVisible() {
float panelInterval = (2.0 + panelSpacing); float panelInterval = (2.0 + panelSpacing);
@ -84,11 +80,11 @@ void ScopeCanvas::setDeviceName(std::string device_name) {
deviceName.append(" "); deviceName.append(" ");
} }
void ScopeCanvas::setPPMMode(bool ppmMode) { void ScopeCanvas::setPPMMode(bool ppmMode_in) {
this->ppmMode = ppmMode; ppmMode = ppmMode_in;
} }
bool ScopeCanvas::getPPMMode() { bool ScopeCanvas::getPPMMode() const {
return ppmMode; return ppmMode;
} }
@ -96,7 +92,7 @@ void ScopeCanvas::setShowDb(bool show) {
this->showDb = show; this->showDb = show;
} }
bool ScopeCanvas::getShowDb() { bool ScopeCanvas::getShowDb() const {
return showDb; return showDb;
} }
@ -110,12 +106,12 @@ void ScopeCanvas::OnPaint(wxPaintEvent& WXUNUSED(event)) {
if (!avData->spectrum) { if (!avData->spectrum) {
scopePanel.setMode(avData->mode); scopePanel.setMode(avData->mode);
if (avData->waveform_points.size()) { if (!avData->waveform_points.empty()) {
scopePanel.setPoints(avData->waveform_points); scopePanel.setPoints(avData->waveform_points);
} }
} else { } else {
if (avData->waveform_points.size()) { if (!avData->waveform_points.empty()) {
spectrumPanel.setPoints(avData->waveform_points); spectrumPanel.setPoints(avData->waveform_points);
spectrumPanel.setFloorValue(avData->fft_floor); spectrumPanel.setFloorValue(avData->fft_floor);
spectrumPanel.setCeilValue(avData->fft_ceil); spectrumPanel.setCeilValue(avData->fft_ceil);

View File

@ -32,11 +32,11 @@ public:
void OnKeyUp(wxKeyEvent& event); void OnKeyUp(wxKeyEvent& event);
void setDeviceName(std::string device_name); void setDeviceName(std::string device_name);
void setPPMMode(bool ppmMode); void setPPMMode(bool ppmMode_in);
bool getPPMMode(); bool getPPMMode() const;
void setShowDb(bool showDb); void setShowDb(bool showDb);
bool getShowDb(); bool getShowDb() const;
bool scopeVisible(); bool scopeVisible();
bool spectrumVisible(); bool spectrumVisible();

View File

@ -48,7 +48,7 @@ void ScopeContext::DrawTunerTitles(bool ppmMode) {
refDrawingFont.drawString("Center Frequency", 0.66f, -1.0 +hPos*shiftFactor, GLFont::GLFONT_ALIGN_CENTER, GLFont::GLFONT_ALIGN_CENTER, 0, 0, true); refDrawingFont.drawString("Center Frequency", 0.66f, -1.0 +hPos*shiftFactor, GLFont::GLFONT_ALIGN_CENTER, GLFont::GLFONT_ALIGN_CENTER, 0, 0, true);
} }
void ScopeContext::DrawDeviceName(std::string deviceName) { void ScopeContext::DrawDeviceName(const std::string& deviceName) {
GLint vp[4]; GLint vp[4];
glGetIntegerv(GL_VIEWPORT, vp); glGetIntegerv(GL_VIEWPORT, vp);
float viewHeight = (float) vp[3]; float viewHeight = (float) vp[3];
@ -56,7 +56,7 @@ void ScopeContext::DrawDeviceName(std::string deviceName) {
glColor3f(0.65f, 0.65f, 0.65f); glColor3f(0.65f, 0.65f, 0.65f);
GLFont::getFont(12, GLFont::getScaleFactor()).drawString(deviceName.c_str(), 1.0, hPos, GLFont::GLFONT_ALIGN_RIGHT, GLFont::GLFONT_ALIGN_CENTER, 0, 0, true); GLFont::getFont(12, GLFont::getScaleFactor()).drawString(deviceName, 1.0, hPos, GLFont::GLFONT_ALIGN_RIGHT, GLFont::GLFONT_ALIGN_CENTER, 0, 0, true);
} }
void ScopeContext::DrawEnd() { void ScopeContext::DrawEnd() {

View File

@ -6,8 +6,6 @@
#include "PrimaryGLContext.h" #include "PrimaryGLContext.h"
#include "Gradient.h" #include "Gradient.h"
#define NUM_WATERFALL_LINES 512
class ScopeCanvas; class ScopeCanvas;
class ScopeContext: public PrimaryGLContext { class ScopeContext: public PrimaryGLContext {
@ -16,7 +14,7 @@ public:
void DrawBegin(bool clear=true); void DrawBegin(bool clear=true);
void DrawTunerTitles(bool ppmMode=false); void DrawTunerTitles(bool ppmMode=false);
void DrawDeviceName(std::string deviceName); void DrawDeviceName(const std::string& deviceName);
void DrawDivider(); void DrawDivider();
void DrawEnd(); void DrawEnd();

View File

@ -17,7 +17,6 @@
#include "CubicSDRDefs.h" #include "CubicSDRDefs.h"
#include "AppFrame.h" #include "AppFrame.h"
#include <algorithm> #include <algorithm>
#include <wx/numformatter.h>
#include "WaterfallCanvas.h" #include "WaterfallCanvas.h"
wxBEGIN_EVENT_TABLE(SpectrumCanvas, wxGLCanvas) EVT_PAINT(SpectrumCanvas::OnPaint) wxBEGIN_EVENT_TABLE(SpectrumCanvas, wxGLCanvas) EVT_PAINT(SpectrumCanvas::OnPaint)
@ -33,7 +32,7 @@ EVT_RIGHT_UP(SpectrumCanvas::OnMouseRightReleased)
wxEND_EVENT_TABLE() wxEND_EVENT_TABLE()
SpectrumCanvas::SpectrumCanvas(wxWindow *parent, const wxGLAttributes& dispAttrs) : SpectrumCanvas::SpectrumCanvas(wxWindow *parent, const wxGLAttributes& dispAttrs) :
InteractiveCanvas(parent, dispAttrs), waterfallCanvas(NULL) { InteractiveCanvas(parent, dispAttrs), waterfallCanvas(nullptr) {
glContext = new PrimaryGLContext(this, &wxGetApp().GetContext(this), wxGetApp().GetContextAttributes()); glContext = new PrimaryGLContext(this, &wxGetApp().GetContext(this), wxGetApp().GetContextAttributes());
@ -46,9 +45,7 @@ SpectrumCanvas::SpectrumCanvas(wxWindow *parent, const wxGLAttributes& dispAttrs
bwChange = 0.0; bwChange = 0.0;
} }
SpectrumCanvas::~SpectrumCanvas() { SpectrumCanvas::~SpectrumCanvas() = default;
}
void SpectrumCanvas::OnPaint(wxPaintEvent& WXUNUSED(event)) { void SpectrumCanvas::OnPaint(wxPaintEvent& WXUNUSED(event)) {
// wxPaintDC dc(this); // wxPaintDC dc(this);
@ -93,11 +90,11 @@ void SpectrumCanvas::OnPaint(wxPaintEvent& WXUNUSED(event)) {
auto demods = wxGetApp().getDemodMgr().getDemodulators(); auto demods = wxGetApp().getDemodMgr().getDemodulators();
auto activeDemodulator = wxGetApp().getDemodMgr().getActiveContextModem(); auto activeDemodulator = wxGetApp().getDemodMgr().getActiveContextModem();
for (int i = 0, iMax = demods.size(); i < iMax; i++) { for (auto & demod : demods) {
if (!demods[i]->isActive()) { if (!demod->isActive()) {
continue; continue;
} }
glContext->DrawDemodInfo(demods[i], ThemeMgr::mgr.currentTheme->fftHighlight, getCenterFrequency(), getBandwidth(), activeDemodulator==demods[i]); glContext->DrawDemodInfo(demod, ThemeMgr::mgr.currentTheme->fftHighlight, getCenterFrequency(), getBandwidth(), activeDemodulator==demod);
} }
if (waterfallCanvas && !activeDemodulator) { if (waterfallCanvas && !activeDemodulator) {

View File

@ -18,7 +18,7 @@ class WaterfallCanvas;
class SpectrumCanvas: public InteractiveCanvas { class SpectrumCanvas: public InteractiveCanvas {
public: public:
SpectrumCanvas(wxWindow *parent, const wxGLAttributes& dispAttrs); SpectrumCanvas(wxWindow *parent, const wxGLAttributes& dispAttrs);
~SpectrumCanvas(); ~SpectrumCanvas() override;
//This is public because it is indeed forwarded from //This is public because it is indeed forwarded from
//AppFrame::OnGlobalKeyDown, because global key handler intercepts //AppFrame::OnGlobalKeyDown, because global key handler intercepts
@ -40,7 +40,7 @@ public:
bool getUseDBOfs(); bool getUseDBOfs();
void setView(long long center_freq_in, int bandwidth_in); void setView(long long center_freq_in, int bandwidth_in);
void disableView(); void disableView() override;
void setScaleFactorEnabled(bool en); void setScaleFactorEnabled(bool en);
void setFFTSize(int fftSize); void setFFTSize(int fftSize);

View File

@ -56,9 +56,7 @@ TuningCanvas::TuningCanvas(wxWindow *parent, const wxGLAttributes& dispAttrs) :
currentPPM = lastPPM = 0; currentPPM = lastPPM = 0;
} }
TuningCanvas::~TuningCanvas() { TuningCanvas::~TuningCanvas() = default;
}
bool TuningCanvas::changed() { bool TuningCanvas::changed() {
@ -182,52 +180,52 @@ void TuningCanvas::StepTuner(ActiveState state, TuningDirection tuningDir, int d
auto activeDemod = wxGetApp().getDemodMgr().getCurrentModem(); auto activeDemod = wxGetApp().getDemodMgr().getCurrentModem();
if (state == TUNING_HOVER_FREQ && activeDemod) { if (state == TUNING_HOVER_FREQ && activeDemod) {
long long freq = activeDemod->getFrequency(); long long demod_freq = activeDemod->getFrequency();
long long diff = abs(wxGetApp().getFrequency() - freq); long long diff = abs(wxGetApp().getFrequency() - demod_freq);
if (zeroOut) { // Zero digits to right if (zeroOut) { // Zero digits to right
double intpart; double intpart;
modf(freq / (exp * 10), &intpart); modf(demod_freq / (exp * 10), &intpart);
freq = intpart * exp * 10; demod_freq = intpart * exp * 10;
} else if (preventCarry) { // Prevent digit from carrying } else if (preventCarry) { // Prevent digit from carrying
bool carried = (long long)((freq) / (exp * 10)) != (long long)((freq + amount) / (exp * 10)) || (bottom && freq < exp); bool carried = (long long)((demod_freq) / (exp * 10)) != (long long)((demod_freq + amount) / (exp * 10)) || (bottom && demod_freq < exp);
freq += carried?(9*-amount):amount; demod_freq += carried ? (9 * -amount) : amount;
} else { } else {
freq += amount; demod_freq += amount;
} }
if (wxGetApp().getSampleRate() / 2 < diff) { if (wxGetApp().getSampleRate() / 2 < diff) {
wxGetApp().setFrequency(freq); wxGetApp().setFrequency(demod_freq);
} }
activeDemod->setTracking(true); activeDemod->setTracking(true);
activeDemod->setFollow(true); activeDemod->setFollow(true);
activeDemod->setFrequency(freq); activeDemod->setFrequency(demod_freq);
if (activeDemod->isDeltaLock()) { if (activeDemod->isDeltaLock()) {
activeDemod->setDeltaLockOfs(activeDemod->getFrequency() - wxGetApp().getFrequency()); activeDemod->setDeltaLockOfs(activeDemod->getFrequency() - wxGetApp().getFrequency());
} }
activeDemod->updateLabel(freq); activeDemod->updateLabel(demod_freq);
} }
if (state == TUNING_HOVER_BW) { if (state == TUNING_HOVER_BW) {
long bw = wxGetApp().getDemodMgr().getLastBandwidth(); long nbw = wxGetApp().getDemodMgr().getLastBandwidth();
if (zeroOut) { // Zero digits to right if (zeroOut) { // Zero digits to right
double intpart; double intpart;
modf(bw / (exp * 10), &intpart); modf(nbw / (exp * 10), &intpart);
bw = intpart * exp * 10; nbw = intpart * exp * 10;
} else if (preventCarry) { // Prevent digit from carrying } else if (preventCarry) { // Prevent digit from carrying
bool carried = (long)((bw) / (exp * 10)) != (long)((bw + amount) / (exp * 10)) || (bottom && bw < exp); bool carried = (long)((nbw) / (exp * 10)) != (long)((nbw + amount) / (exp * 10)) || (bottom && nbw < exp);
bw += carried?(9*-amount):amount; nbw += carried ? (9 * -amount) : amount;
} else { } else {
bw += amount; nbw += amount;
} }
if (bw > CHANNELIZER_RATE_MAX) { if (nbw > CHANNELIZER_RATE_MAX) {
bw = CHANNELIZER_RATE_MAX; nbw = CHANNELIZER_RATE_MAX;
} }
wxGetApp().getDemodMgr().setLastBandwidth(bw); wxGetApp().getDemodMgr().setLastBandwidth(nbw);
if (activeDemod) { if (activeDemod) {
activeDemod->setBandwidth(wxGetApp().getDemodMgr().getLastBandwidth()); activeDemod->setBandwidth(wxGetApp().getDemodMgr().getLastBandwidth());
@ -298,12 +296,10 @@ void TuningCanvas::OnIdle(wxIdleEvent & /* event */) {
void TuningCanvas::OnMouseMoved(wxMouseEvent& event) { void TuningCanvas::OnMouseMoved(wxMouseEvent& event) {
InteractiveCanvas::OnMouseMoved(event); InteractiveCanvas::OnMouseMoved(event);
int index = 0;
top = mouseTracker.getMouseY() >= 0.5; top = mouseTracker.getMouseY() >= 0.5;
bottom = mouseTracker.getMouseY() <= 0.5; bottom = mouseTracker.getMouseY() <= 0.5;
index = glContext->GetTunerDigitIndex(mouseTracker.getMouseX(), 11, freqDP, freqW); // freq int index = glContext->GetTunerDigitIndex(mouseTracker.getMouseX(), 11, freqDP, freqW); // freq
if (index > 0) { if (index > 0) {
hoverIndex = index; hoverIndex = index;
hoverState = altDown?TUNING_HOVER_PPM:TUNING_HOVER_FREQ; hoverState = altDown?TUNING_HOVER_PPM:TUNING_HOVER_FREQ;

View File

@ -24,7 +24,7 @@ public:
TUNING_DIRECTION_DOWN, TUNING_DIRECTION_UP TUNING_DIRECTION_DOWN, TUNING_DIRECTION_UP
}; };
TuningCanvas(wxWindow *parent, const wxGLAttributes& dispAttrs); TuningCanvas(wxWindow *parent, const wxGLAttributes& dispAttrs);
~TuningCanvas(); ~TuningCanvas() override;
void setHelpTip(std::string tip); void setHelpTip(std::string tip);
bool changed(); bool changed();

View File

@ -9,11 +9,11 @@
// http://stackoverflow.com/questions/7276826/c-format-number-with-commas // http://stackoverflow.com/questions/7276826/c-format-number-with-commas
class comma_numpunct: public std::numpunct<char> { class comma_numpunct: public std::numpunct<char> {
protected: protected:
virtual char do_thousands_sep() const { char do_thousands_sep() const override {
return ','; return ',';
} }
virtual std::string do_grouping() const { std::string do_grouping() const override {
return "\03"; return "\03";
} }
}; };
@ -120,7 +120,7 @@ void TuningContext::DrawTuner(long long freq, int count, float displayPos, float
} }
void TuningContext::DrawTunerDigitBox(int index, int count, float displayPos, float displayWidth, RGBA4f /* c */) { void TuningContext::DrawTunerDigitBox(int index, int count, float displayPos, float displayWidth, const RGBA4f& /* c */) {
GLint vp[4]; GLint vp[4];
glGetIntegerv( GL_VIEWPORT, vp); glGetIntegerv( GL_VIEWPORT, vp);
@ -160,7 +160,7 @@ int TuningContext::GetTunerDigitIndex(float mPos, int count, float displayPos, f
return count - index; return count - index;
} }
void TuningContext::DrawTunerBarIndexed(int start, int end, int count, float displayPos, float displayWidth, RGBA4f color, float /* alpha */, bool top, void TuningContext::DrawTunerBarIndexed(int start, int end, int count, float displayPos, float displayWidth, const RGBA4f& color, float /* alpha */, bool top,
bool bottom) { bool bottom) {
float ofs = (displayWidth / (float) count); float ofs = (displayWidth / (float) count);
float p2 = displayPos + ofs * (float) (count - start + 1); float p2 = displayPos + ofs * (float) (count - start + 1);

View File

@ -6,8 +6,6 @@
#include "PrimaryGLContext.h" #include "PrimaryGLContext.h"
#include "Gradient.h" #include "Gradient.h"
#define NUM_WATERFALL_LINES 512
class TuningCanvas; class TuningCanvas;
class TuningContext: public PrimaryGLContext { class TuningContext: public PrimaryGLContext {
@ -17,9 +15,9 @@ public:
void DrawBegin(); void DrawBegin();
void Draw(float r, float g, float b, float a, float p1, float p2); void Draw(float r, float g, float b, float a, float p1, float p2);
void DrawTuner(long long freq, int count, float displayPos, float displayWidth); void DrawTuner(long long freq, int count, float displayPos, float displayWidth);
void DrawTunerDigitBox(int index, int count, float displayPos, float displayWidth, RGBA4f c); static void DrawTunerDigitBox(int index, int count, float displayPos, float displayWidth, const RGBA4f& c);
int GetTunerDigitIndex(float mPos, int count, float displayPos, float displayWidth); int GetTunerDigitIndex(float mPos, int count, float displayPos, float displayWidth);
void DrawTunerBarIndexed(int start, int end, int count, float displayPos, float displayWidth, RGBA4f color, float alpha, bool top, bool bottom); void DrawTunerBarIndexed(int start, int end, int count, float displayPos, float displayWidth, const RGBA4f& color, float alpha, bool top, bool bottom);
void DrawDemodFreqBw(long long freq, unsigned int bw, long long center); void DrawDemodFreqBw(long long freq, unsigned int bw, long long center);
void DrawEnd(); void DrawEnd();

View File

@ -53,8 +53,7 @@ WaterfallCanvas::WaterfallCanvas(wxWindow *parent, const wxGLAttributes& dispAtt
fft_size_changed.store(false); fft_size_changed.store(false);
} }
WaterfallCanvas::~WaterfallCanvas() { WaterfallCanvas::~WaterfallCanvas() = default;
}
void WaterfallCanvas::setup(unsigned int fft_size_in, int waterfall_lines_in) { void WaterfallCanvas::setup(unsigned int fft_size_in, int waterfall_lines_in) {
if (fft_size == fft_size_in && waterfall_lines_in == waterfall_lines) { if (fft_size == fft_size_in && waterfall_lines_in == waterfall_lines) {
@ -333,23 +332,23 @@ void WaterfallCanvas::OnPaint(wxPaintEvent& WXUNUSED(event)) {
glContext->setHoverAlpha(0); glContext->setHoverAlpha(0);
for (int i = 0, iMax = demods.size(); i < iMax; i++) { for (auto & demod : demods) {
if (!demods[i]->isActive()) { if (!demod->isActive()) {
continue; continue;
} }
if (activeDemodulator == demods[i] || lastActiveDemodulator == demods[i]) { if (activeDemodulator == demod || lastActiveDemodulator == demod) {
continue; continue;
} }
glContext->DrawDemod(demods[i], currentTheme->waterfallHighlight, currentCenterFreq, currentBandwidth); glContext->DrawDemod(demod, currentTheme->waterfallHighlight, currentCenterFreq, currentBandwidth);
} }
for (int i = 0, iMax = demods.size(); i < iMax; i++) { for (auto & demod : demods) {
demods[i]->getVisualCue()->step(); demod->getVisualCue()->step();
int squelchBreak = demods[i]->getVisualCue()->getSquelchBreak(); int squelchBreak = demod->getVisualCue()->getSquelchBreak();
if (squelchBreak) { if (squelchBreak) {
glContext->setHoverAlpha((float(squelchBreak) / 60.0)); glContext->setHoverAlpha((float(squelchBreak) / 60.0));
glContext->DrawDemod(demods[i], currentTheme->waterfallHover, currentCenterFreq, currentBandwidth); glContext->DrawDemod(demod, currentTheme->waterfallHover, currentCenterFreq, currentBandwidth);
} }
} }
@ -452,15 +451,15 @@ void WaterfallCanvas::OnKeyDown(wxKeyEvent& event) {
if (wxGetApp().getDemodMgr().getActiveContextModem()) { if (wxGetApp().getDemodMgr().getActiveContextModem()) {
wxGetApp().setFrequency(wxGetApp().getDemodMgr().getActiveContextModem()->getFrequency()); wxGetApp().setFrequency(wxGetApp().getDemodMgr().getActiveContextModem()->getFrequency());
} else if (mouseTracker.mouseInView()) { } else if (mouseTracker.mouseInView()) {
long long freq = getFrequencyAt(mouseTracker.getMouseX()); long long nfreq = getFrequencyAt(mouseTracker.getMouseX());
int snap = wxGetApp().getFrequencySnap(); int snap = wxGetApp().getFrequencySnap();
if (snap > 1) { if (snap > 1) {
freq = roundf((float)freq/(float)snap)*snap; nfreq = roundf((float)nfreq / (float)snap) * snap;
} }
wxGetApp().setFrequency(freq); wxGetApp().setFrequency(nfreq);
} }
#ifdef USE_HAMLIB #ifdef USE_HAMLIB
if (wxGetApp().rigIsActive() && (!wxGetApp().getRigThread()->getControlMode() || wxGetApp().getRigThread()->getCenterLock())) { if (wxGetApp().rigIsActive() && (!wxGetApp().getRigThread()->getControlMode() || wxGetApp().getRigThread()->getCenterLock())) {
@ -504,13 +503,12 @@ void WaterfallCanvas::updateHoverState() {
} else { } else {
setStatusText("Click and drag to set the current demodulator range."); setStatusText("Click and drag to set the current demodulator range.");
} }
} else if (demodsHover.size() && !shiftDown) { } else if (!demodsHover.empty() && !shiftDown) {
long near_dist = getBandwidth(); long near_dist = getBandwidth();
DemodulatorInstancePtr activeDemodulator = nullptr; DemodulatorInstancePtr activeDemodulator = nullptr;
for (int i = 0, iMax = demodsHover.size(); i < iMax; i++) { for (auto demod : demodsHover) {
auto demod = demodsHover[i];
long long freqDiff = demod->getFrequency() - freqPos; long long freqDiff = demod->getFrequency() - freqPos;
long halfBw = (demod->getBandwidth() / 2); long halfBw = (demod->getBandwidth() / 2);
long long currentBw = getBandwidth(); long long currentBw = getBandwidth();
@ -708,7 +706,7 @@ void WaterfallCanvas::OnMouseReleased(wxMouseEvent& event) {
if (dragState == WF_DRAG_NONE) { if (dragState == WF_DRAG_NONE) {
if (!isNew && wxGetApp().getDemodMgr().getDemodulators().size()) { if (!isNew && !wxGetApp().getDemodMgr().getDemodulators().empty()) {
mgr->updateLastState(); mgr->updateLastState();
demod = wxGetApp().getDemodMgr().getCurrentModem(); demod = wxGetApp().getDemodMgr().getCurrentModem();
} else { } else {
@ -809,7 +807,7 @@ void WaterfallCanvas::OnMouseReleased(wxMouseEvent& event) {
} }
if (!isNew && wxGetApp().getDemodMgr().getDemodulators().size()) { if (!isNew && !wxGetApp().getDemodMgr().getDemodulators().empty()) {
mgr->updateLastState(); mgr->updateLastState();
demod = wxGetApp().getDemodMgr().getCurrentModem(); demod = wxGetApp().getDemodMgr().getCurrentModem();
} else { } else {

View File

@ -24,7 +24,7 @@ public:
WaterfallCanvas(wxWindow *parent, const wxGLAttributes& dispAttrs); WaterfallCanvas(wxWindow *parent, const wxGLAttributes& dispAttrs);
void setup(unsigned int fft_size_in, int waterfall_lines_in); void setup(unsigned int fft_size_in, int waterfall_lines_in);
void setFFTSize(unsigned int fft_size_in); void setFFTSize(unsigned int fft_size_in);
~WaterfallCanvas(); ~WaterfallCanvas() override;
DragState getDragState(); DragState getDragState();
DragState getNextDragState(); DragState getNextDragState();