mirror of
https://github.com/cjcliffe/CubicSDR.git
synced 2024-11-14 16:11:47 -05:00
Cleanup: visual ui / interface panels
This commit is contained in:
parent
690896f65d
commit
a0f1ccf68d
@ -27,7 +27,7 @@ GLPanel::GLPanel() : fillType(GLPANEL_FILL_SOLID), contentsVisible(true), visibl
|
||||
}
|
||||
|
||||
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) {
|
||||
glPoints.reserve(2 * 4);
|
||||
@ -36,10 +36,10 @@ void GLPanel::genArrays() {
|
||||
glColors.resize(4 * 4);
|
||||
|
||||
float pts[2 * 4] = {
|
||||
min, min,
|
||||
min, max,
|
||||
max, max,
|
||||
max, min
|
||||
gmin, gmin,
|
||||
gmin, gmax,
|
||||
gmax, gmax,
|
||||
gmax, gmin
|
||||
};
|
||||
|
||||
RGBA4f c[4];
|
||||
@ -73,15 +73,15 @@ void GLPanel::genArrays() {
|
||||
|
||||
if (fillType == GLPANEL_FILL_GRAD_BAR_X) {
|
||||
float pts[2 * 8] = {
|
||||
min, min,
|
||||
min, max,
|
||||
mid, max,
|
||||
mid, min,
|
||||
|
||||
mid, min,
|
||||
mid, max,
|
||||
max, max,
|
||||
max, min
|
||||
gmin, gmin,
|
||||
gmin, gmax,
|
||||
gmid, gmax,
|
||||
gmid, gmin,
|
||||
|
||||
gmid, gmin,
|
||||
gmid, gmax,
|
||||
gmax, gmax,
|
||||
gmax, gmin
|
||||
};
|
||||
glPoints.assign(pts, pts + (2 * 8));
|
||||
|
||||
@ -93,15 +93,15 @@ void GLPanel::genArrays() {
|
||||
|
||||
} else if (fillType == GLPANEL_FILL_GRAD_BAR_Y) {
|
||||
float pts[2 * 8] = {
|
||||
min, min,
|
||||
min, mid,
|
||||
max, mid,
|
||||
max, min,
|
||||
|
||||
min, mid,
|
||||
min, max,
|
||||
max, max,
|
||||
max, mid
|
||||
gmin, gmin,
|
||||
gmin, gmid,
|
||||
gmax, gmid,
|
||||
gmax, gmin,
|
||||
|
||||
gmin, gmid,
|
||||
gmin, gmax,
|
||||
gmax, gmax,
|
||||
gmax, gmid
|
||||
};
|
||||
glPoints.assign(pts, pts + (2 * 8));
|
||||
|
||||
@ -154,11 +154,11 @@ float GLPanel::getHeight() {
|
||||
return size[1];
|
||||
}
|
||||
|
||||
float GLPanel::getWidthPx() {
|
||||
float GLPanel::getWidthPx() const {
|
||||
return pdim.x;
|
||||
}
|
||||
|
||||
float GLPanel::getHeightPx() {
|
||||
float GLPanel::getHeightPx() const {
|
||||
return pdim.y;
|
||||
}
|
||||
|
||||
@ -179,8 +179,8 @@ void GLPanel::setCoordinateSystem(GLPanelCoordinateSystem coord_in) {
|
||||
genArrays();
|
||||
}
|
||||
|
||||
bool GLPanel::hitTest(CubicVR::vec2 pos, CubicVR::vec2 &result) {
|
||||
CubicVR::vec4 hitPos = CubicVR::mat4::vec4_multiply(CubicVR::vec4(pos.x, pos.y, 0.0, 1.0), transformInverse);
|
||||
bool GLPanel::hitTest(CubicVR::vec2 pos_in, CubicVR::vec2 &result) const {
|
||||
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) {
|
||||
result.x = hitPos.x;
|
||||
@ -197,12 +197,12 @@ void GLPanel::setFill(GLPanelFillType fill_mode) {
|
||||
genArrays();
|
||||
}
|
||||
|
||||
void GLPanel::setFillColor(RGBA4f color1) {
|
||||
void GLPanel::setFillColor(const RGBA4f& color1) {
|
||||
fill[0] = color1;
|
||||
genArrays();
|
||||
}
|
||||
|
||||
void GLPanel::setFillColor(RGBA4f color1, RGBA4f color2) {
|
||||
void GLPanel::setFillColor(const RGBA4f& color1, const RGBA4f& color2) {
|
||||
fill[0] = color1;
|
||||
fill[1] = color2;
|
||||
genArrays();
|
||||
@ -213,7 +213,7 @@ void GLPanel::setMarginPx(float marg) {
|
||||
}
|
||||
|
||||
|
||||
void GLPanel::setBorderColor(RGBA4f clr) {
|
||||
void GLPanel::setBorderColor(const RGBA4f& clr) {
|
||||
borderColor = clr;
|
||||
}
|
||||
|
||||
@ -234,7 +234,7 @@ void GLPanel::setBlend(GLuint src, GLuint dst) {
|
||||
}
|
||||
|
||||
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()) {
|
||||
children.push_back(childPanel);
|
||||
@ -242,7 +242,7 @@ void GLPanel::addChild(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()) {
|
||||
children.erase(i);
|
||||
@ -250,7 +250,7 @@ void GLPanel::removeChild(GLPanel *childPanel) {
|
||||
}
|
||||
|
||||
void GLPanel::drawChildren() {
|
||||
if (children.size()) {
|
||||
if (!children.empty()) {
|
||||
std::vector<GLPanel *>::iterator 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() {
|
||||
float min = -1.0, max = 1.0;
|
||||
float gmin = -1.0, gmax = 1.0;
|
||||
|
||||
glLoadMatrixf(transform.to_ptr());
|
||||
|
||||
@ -330,32 +330,32 @@ void GLPanel::draw() {
|
||||
if (borderPx.left) {
|
||||
glLineWidth(borderPx.left);
|
||||
glBegin(GL_LINES);
|
||||
glVertex2f(min, min);
|
||||
glVertex2f(min, max);
|
||||
glVertex2f(gmin, gmin);
|
||||
glVertex2f(gmin, gmax);
|
||||
glEnd();
|
||||
}
|
||||
|
||||
if (borderPx.right) {
|
||||
glLineWidth(borderPx.right);
|
||||
glBegin(GL_LINES);
|
||||
glVertex2f(max, min);
|
||||
glVertex2f(max, max);
|
||||
glVertex2f(gmax, gmin);
|
||||
glVertex2f(gmax, gmax);
|
||||
glEnd();
|
||||
}
|
||||
|
||||
if (borderPx.top) {
|
||||
glLineWidth(borderPx.top);
|
||||
glBegin(GL_LINES);
|
||||
glVertex2f(min, min);
|
||||
glVertex2f(max, min);
|
||||
glVertex2f(gmin, gmin);
|
||||
glVertex2f(gmax, gmin);
|
||||
glEnd();
|
||||
}
|
||||
|
||||
if (borderPx.bottom) {
|
||||
glLineWidth(borderPx.bottom);
|
||||
glBegin(GL_LINES);
|
||||
glVertex2f(min, max);
|
||||
glVertex2f(max, max);
|
||||
glVertex2f(gmin, gmax);
|
||||
glVertex2f(gmax, gmax);
|
||||
glEnd();
|
||||
}
|
||||
|
||||
|
@ -63,7 +63,7 @@ public:
|
||||
std::vector<GLPanel *> children;
|
||||
|
||||
GLPanel();
|
||||
virtual ~GLPanel() {};
|
||||
virtual ~GLPanel() = default;;
|
||||
|
||||
void setPosition(float x, float y);
|
||||
|
||||
@ -71,18 +71,18 @@ public:
|
||||
void setSize(float w, float h);
|
||||
float getWidth();
|
||||
float getHeight();
|
||||
float getWidthPx();
|
||||
float getHeightPx();
|
||||
float getWidthPx() const;
|
||||
float getHeightPx() const;
|
||||
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 setFillColor(RGBA4f color1);
|
||||
void setFillColor(RGBA4f color1, RGBA4f color2);
|
||||
void setFillColor(const RGBA4f& color1);
|
||||
void setFillColor(const RGBA4f& color1, const RGBA4f& color2);
|
||||
void setMarginPx(float marg);
|
||||
|
||||
void setBorderColor(RGBA4f clr);
|
||||
void setBorderColor(const RGBA4f& clr);
|
||||
void setBorderPx(float bord);
|
||||
void setBorderPx(float bordl, float bordr, float bordt, float bordb);
|
||||
|
||||
@ -107,7 +107,7 @@ private:
|
||||
public:
|
||||
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);
|
||||
std::string getText();
|
||||
@ -119,5 +119,5 @@ public:
|
||||
|
||||
}
|
||||
|
||||
void drawPanelContents();
|
||||
void drawPanelContents() override;
|
||||
};
|
||||
|
@ -15,7 +15,6 @@
|
||||
|
||||
#include "CubicSDR.h"
|
||||
#include "CubicSDRDefs.h"
|
||||
#include "AppFrame.h"
|
||||
#include <algorithm>
|
||||
|
||||
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());
|
||||
}
|
||||
|
||||
UITestCanvas::~UITestCanvas() {
|
||||
|
||||
}
|
||||
UITestCanvas::~UITestCanvas() = default;
|
||||
|
||||
void UITestCanvas::OnPaint(wxPaintEvent& WXUNUSED(event)) {
|
||||
// wxPaintDC dc(this);
|
||||
@ -61,7 +58,7 @@ void UITestCanvas::OnIdle(wxIdleEvent& /* event */) {
|
||||
|
||||
void UITestCanvas::OnMouseMoved(wxMouseEvent& event) {
|
||||
InteractiveCanvas::OnMouseMoved(event);
|
||||
|
||||
|
||||
}
|
||||
|
||||
void UITestCanvas::OnMouseDown(wxMouseEvent& event) {
|
||||
|
@ -18,19 +18,19 @@
|
||||
class UITestCanvas: public InteractiveCanvas {
|
||||
public:
|
||||
UITestCanvas(wxWindow *parent, const wxGLAttributes& dispAttrs);
|
||||
~UITestCanvas();
|
||||
~UITestCanvas() override;
|
||||
|
||||
private:
|
||||
void OnPaint(wxPaintEvent& event);
|
||||
void OnIdle(wxIdleEvent &event);
|
||||
|
||||
|
||||
void OnMouseMoved(wxMouseEvent& event);
|
||||
void OnMouseDown(wxMouseEvent& event);
|
||||
void OnMouseWheelMoved(wxMouseEvent& event);
|
||||
void OnMouseReleased(wxMouseEvent& event);
|
||||
void OnMouseEnterWindow(wxMouseEvent& event);
|
||||
void OnMouseLeftWindow(wxMouseEvent& event);
|
||||
|
||||
|
||||
UITestContext *glContext;
|
||||
|
||||
wxDECLARE_EVENT_TABLE();
|
||||
|
@ -4,17 +4,15 @@
|
||||
// SPDX-License-Identifier: GPL-2.0+
|
||||
|
||||
#include "ColorTheme.h"
|
||||
#include "CubicSDR.h"
|
||||
#include "CubicSDRDefs.h"
|
||||
|
||||
ThemeMgr ThemeMgr::mgr;
|
||||
|
||||
void ThemeMgr::setTheme(int themeId) {
|
||||
currentTheme = themes[themeId];
|
||||
this->themeId = themeId;
|
||||
void ThemeMgr::setTheme(int themeId_in) {
|
||||
currentTheme = themes[themeId_in];
|
||||
themeId = themeId_in;
|
||||
}
|
||||
|
||||
int ThemeMgr::getTheme() {
|
||||
int ThemeMgr::getTheme() const {
|
||||
return themeId;
|
||||
}
|
||||
|
||||
|
@ -27,24 +27,24 @@ public:
|
||||
r(r), g(g), b(b), a(a) {
|
||||
}
|
||||
|
||||
RGBA4f() :
|
||||
RGBA4f(0, 0, 0) {
|
||||
}
|
||||
|
||||
~RGBA4f() {
|
||||
}
|
||||
|
||||
RGBA4f & operator=(const RGBA4f &other) {
|
||||
RGBA4f(const RGBA4f &other) {
|
||||
r = other.r;
|
||||
g = other.g;
|
||||
b = other.b;
|
||||
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(
|
||||
(unsigned char) std::min((r * 255.0), 255.0),
|
||||
(unsigned char) std::min((g * 255.0), 255.0),
|
||||
@ -90,8 +90,8 @@ public:
|
||||
~ThemeMgr();
|
||||
ColorTheme *currentTheme;
|
||||
std::map<int, ColorTheme *> themes;
|
||||
void setTheme(int themeId);
|
||||
int getTheme();
|
||||
void setTheme(int themeId_in);
|
||||
int getTheme() const;
|
||||
int themeId;
|
||||
|
||||
static ThemeMgr mgr;
|
||||
|
@ -14,8 +14,6 @@
|
||||
#endif
|
||||
|
||||
#include "CubicSDR.h"
|
||||
#include "CubicSDRDefs.h"
|
||||
#include "AppFrame.h"
|
||||
#include <algorithm>
|
||||
#include <cmath>
|
||||
|
||||
@ -46,9 +44,7 @@ GainCanvas::GainCanvas(wxWindow *parent, const wxGLAttributes& dispAttrs) :
|
||||
userGainAsChanged = false;
|
||||
}
|
||||
|
||||
GainCanvas::~GainCanvas() {
|
||||
|
||||
}
|
||||
GainCanvas::~GainCanvas() = default;
|
||||
|
||||
void GainCanvas::OnPaint(wxPaintEvent& WXUNUSED(event)) {
|
||||
// wxPaintDC dc(this);
|
||||
@ -157,8 +153,6 @@ void GainCanvas::OnMouseDown(wxMouseEvent& event) {
|
||||
void GainCanvas::OnMouseWheelMoved(wxMouseEvent& event) {
|
||||
InteractiveCanvas::OnMouseWheelMoved(event);
|
||||
|
||||
CubicVR::vec2 hitResult;
|
||||
|
||||
CubicVR::vec2 mpos = mouseTracker.getGLXY();
|
||||
|
||||
for (auto gi : gainPanels) {
|
||||
@ -217,9 +211,6 @@ void GainCanvas::updateGainUI() {
|
||||
//to take into account a user gain change. Doesn't matter,
|
||||
//UpdateGainValues() takes cares of updating the true value realtime.
|
||||
gains = devInfo->getGains(SOAPY_SDR_RX, 0);
|
||||
|
||||
SDRRangeMap::iterator gi;
|
||||
|
||||
numGains = gains.size();
|
||||
float i = 0;
|
||||
|
||||
@ -232,15 +223,15 @@ void GainCanvas::updateGainUI() {
|
||||
startPos = spacing/2.0;
|
||||
barHeight = 1.0f;
|
||||
|
||||
while (gainPanels.size()) {
|
||||
while (!gainPanels.empty()) {
|
||||
MeterPanel *mDel = gainPanels.back();
|
||||
gainPanels.pop_back();
|
||||
bgPanel.removeChild(mDel);
|
||||
delete mDel;
|
||||
}
|
||||
|
||||
for (auto gi : gains) {
|
||||
MeterPanel *mPanel = new MeterPanel(gi.first, gi.second.minimum(), gi.second.maximum(), devConfig->getGain(gi.first,wxGetApp().getGain(gi.first)));
|
||||
for (const auto& gi : gains) {
|
||||
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;
|
||||
mPanel->setPosition(midPos, 0);
|
||||
@ -271,14 +262,13 @@ bool GainCanvas::updateGainValues() {
|
||||
DeviceConfig *devConfig = wxGetApp().getConfig()->getDevice(devInfo->getDeviceId());
|
||||
|
||||
gains = devInfo->getGains(SOAPY_SDR_RX, 0);
|
||||
SDRRangeMap::iterator gi;
|
||||
|
||||
size_t numGainsToRefresh = std::min(gains.size(), gainPanels.size());
|
||||
size_t panelIndex = 0;
|
||||
|
||||
//actually the order of gains iteration should be constant because map of string,
|
||||
//and gainPanels were built in that order in updateGainUI()
|
||||
for (auto gi : gains) {
|
||||
for (const auto& gi : gains) {
|
||||
|
||||
if (panelIndex >= numGainsToRefresh) {
|
||||
break;
|
||||
|
@ -22,7 +22,7 @@
|
||||
class GainCanvas: public InteractiveCanvas {
|
||||
public:
|
||||
GainCanvas(wxWindow *parent, const wxGLAttributes& dispAttrs);
|
||||
~GainCanvas();
|
||||
~GainCanvas() override;
|
||||
|
||||
void setHelpTip(std::string tip);
|
||||
void updateGainUI();
|
||||
|
@ -32,7 +32,7 @@ void ImagePanel::render(wxDC& dc) {
|
||||
double destw = destSize.GetWidth();
|
||||
double desth = destSize.GetHeight();
|
||||
|
||||
double sf = 1.0, wf, hf;
|
||||
double sf, wf, hf;
|
||||
|
||||
wf = destw / imagew;
|
||||
hf = desth / imageh;
|
||||
|
@ -14,9 +14,6 @@
|
||||
#endif
|
||||
|
||||
#include "CubicSDR.h"
|
||||
#include "CubicSDRDefs.h"
|
||||
#include "AppFrame.h"
|
||||
#include <algorithm>
|
||||
|
||||
#include <wx/numformatter.h>
|
||||
|
||||
@ -27,8 +24,7 @@ InteractiveCanvas::InteractiveCanvas(wxWindow *parent, const wxGLAttributes& dis
|
||||
mouseTracker.setTarget(this);
|
||||
}
|
||||
|
||||
InteractiveCanvas::~InteractiveCanvas() {
|
||||
}
|
||||
InteractiveCanvas::~InteractiveCanvas() = default;
|
||||
|
||||
void InteractiveCanvas::setView(long long center_freq_in, long long bandwidth_in) {
|
||||
isView = true;
|
||||
@ -44,7 +40,7 @@ void InteractiveCanvas::disableView() {
|
||||
lastBandwidth = 0;
|
||||
}
|
||||
|
||||
bool InteractiveCanvas::getViewState() {
|
||||
bool InteractiveCanvas::getViewState() const {
|
||||
return isView;
|
||||
}
|
||||
|
||||
@ -66,7 +62,7 @@ void InteractiveCanvas::setCenterFrequency(long long center_freq_in) {
|
||||
centerFreq = center_freq_in;
|
||||
}
|
||||
|
||||
long long InteractiveCanvas::getCenterFrequency() {
|
||||
long long InteractiveCanvas::getCenterFrequency() const {
|
||||
if (isView) {
|
||||
return centerFreq;
|
||||
} else {
|
||||
@ -78,7 +74,7 @@ void InteractiveCanvas::setBandwidth(long long bandwidth_in) {
|
||||
bandwidth = bandwidth_in;
|
||||
}
|
||||
|
||||
long long InteractiveCanvas::getBandwidth() {
|
||||
long long InteractiveCanvas::getBandwidth() const {
|
||||
if (isView) {
|
||||
return bandwidth;
|
||||
} else {
|
||||
@ -90,15 +86,15 @@ MouseTracker *InteractiveCanvas::getMouseTracker() {
|
||||
return &mouseTracker;
|
||||
}
|
||||
|
||||
bool InteractiveCanvas::isAltDown() {
|
||||
bool InteractiveCanvas::isAltDown() const {
|
||||
return altDown;
|
||||
}
|
||||
|
||||
bool InteractiveCanvas::isCtrlDown() {
|
||||
bool InteractiveCanvas::isCtrlDown() const {
|
||||
return ctrlDown;
|
||||
}
|
||||
|
||||
bool InteractiveCanvas::isShiftDown() {
|
||||
bool InteractiveCanvas::isShiftDown() const {
|
||||
return shiftDown;
|
||||
}
|
||||
|
||||
|
@ -13,28 +13,28 @@
|
||||
class InteractiveCanvas: public wxGLCanvas {
|
||||
public:
|
||||
InteractiveCanvas(wxWindow *parent, const wxGLAttributes& dispAttrs);
|
||||
virtual ~InteractiveCanvas();
|
||||
~InteractiveCanvas() override;
|
||||
|
||||
long long getFrequencyAt(float x);
|
||||
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 disableView();
|
||||
bool getViewState();
|
||||
bool getViewState() const;
|
||||
|
||||
void setCenterFrequency(long long center_freq_in);
|
||||
long long getCenterFrequency();
|
||||
long long getCenterFrequency() const;
|
||||
|
||||
void setBandwidth(long long bandwidth_in);
|
||||
long long getBandwidth();
|
||||
long long getBandwidth() const;
|
||||
|
||||
MouseTracker *getMouseTracker();
|
||||
bool isMouseInView();
|
||||
bool isMouseDown();
|
||||
|
||||
bool isAltDown();
|
||||
bool isCtrlDown();
|
||||
bool isShiftDown();
|
||||
bool isAltDown() const;
|
||||
bool isCtrlDown() const;
|
||||
bool isShiftDown() const;
|
||||
|
||||
protected:
|
||||
void OnKeyDown(wxKeyEvent& event);
|
||||
|
@ -36,15 +36,13 @@ MeterCanvas::MeterCanvas(wxWindow *parent, const wxGLAttributes& dispAttrs) :
|
||||
glContext = new MeterContext(this, &wxGetApp().GetContext(this), wxGetApp().GetContextAttributes());
|
||||
}
|
||||
|
||||
MeterCanvas::~MeterCanvas() {
|
||||
|
||||
}
|
||||
MeterCanvas::~MeterCanvas() = default;
|
||||
|
||||
void MeterCanvas::setLevel(float level_in) {
|
||||
level = level_in;
|
||||
Refresh();
|
||||
}
|
||||
float MeterCanvas::getLevel() {
|
||||
float MeterCanvas::getLevel() const {
|
||||
return level;
|
||||
}
|
||||
|
||||
@ -68,7 +66,7 @@ void MeterCanvas::setInputValue(float slider_in) {
|
||||
Refresh();
|
||||
}
|
||||
|
||||
bool MeterCanvas::inputChanged() {
|
||||
bool MeterCanvas::inputChanged() const {
|
||||
return (inputValue != userInputValue);
|
||||
}
|
||||
|
||||
@ -77,8 +75,8 @@ float MeterCanvas::getInputValue() {
|
||||
return userInputValue;
|
||||
}
|
||||
|
||||
void MeterCanvas::setShowUserInput(bool showUserInput) {
|
||||
this->showUserInput = showUserInput;
|
||||
void MeterCanvas::setShowUserInput(bool showUserInput_in) {
|
||||
showUserInput = showUserInput_in;
|
||||
}
|
||||
|
||||
void MeterCanvas::OnPaint(wxPaintEvent& WXUNUSED(event)) {
|
||||
@ -151,7 +149,7 @@ void MeterCanvas::OnMouseWheelMoved(wxMouseEvent& event) {
|
||||
InteractiveCanvas::OnMouseWheelMoved(event);
|
||||
float movement = 3.0 * (float)event.GetWheelRotation();
|
||||
|
||||
float currentValue = 0;
|
||||
float currentValue;
|
||||
if (showUserInput) {
|
||||
currentValue = userInputValue;
|
||||
} else {
|
||||
|
@ -18,19 +18,19 @@
|
||||
class MeterCanvas: public InteractiveCanvas {
|
||||
public:
|
||||
MeterCanvas(wxWindow *parent, const wxGLAttributes& dispAttrs);
|
||||
~MeterCanvas();
|
||||
~MeterCanvas() override;
|
||||
|
||||
void setLevel(float level_in);
|
||||
float getLevel();
|
||||
float getLevel() const;
|
||||
|
||||
void setMax(float max_in);
|
||||
void setMin(float max_in);
|
||||
|
||||
void setUserInputValue(float slider_in);
|
||||
void setInputValue(float slider_in);
|
||||
bool inputChanged();
|
||||
bool inputChanged() const;
|
||||
float getInputValue();
|
||||
void setShowUserInput(bool showUserInput);
|
||||
void setShowUserInput(bool showUserInput_in);
|
||||
|
||||
void setHelpTip(std::string tip);
|
||||
|
||||
|
@ -6,8 +6,6 @@
|
||||
#include "PrimaryGLContext.h"
|
||||
#include "Gradient.h"
|
||||
|
||||
#define NUM_WATERFALL_LINES 512
|
||||
|
||||
class MeterCanvas;
|
||||
|
||||
class MeterContext: public PrimaryGLContext {
|
||||
|
@ -35,9 +35,7 @@ InteractiveCanvas(parent, dispAttrs), numChoices(0), currentSelection(-1), toggl
|
||||
highlightColor = RGBA4f(1.0,1.0,1.0,1.0);
|
||||
}
|
||||
|
||||
ModeSelectorCanvas::~ModeSelectorCanvas() {
|
||||
|
||||
}
|
||||
ModeSelectorCanvas::~ModeSelectorCanvas() = default;
|
||||
|
||||
int ModeSelectorCanvas::getHoveredSelection() {
|
||||
if (!mouseTracker.mouseInView()) {
|
||||
@ -163,7 +161,7 @@ void ModeSelectorCanvas::addChoice(std::string label) {
|
||||
numChoices = selections.size();
|
||||
}
|
||||
|
||||
void ModeSelectorCanvas::setSelection(std::string label) {
|
||||
void ModeSelectorCanvas::setSelection(const std::string& label) {
|
||||
for (int i = 0; i < numChoices; i++) {
|
||||
if (selections[i].label == label) {
|
||||
currentSelection = i;
|
||||
@ -201,11 +199,11 @@ int ModeSelectorCanvas::getSelection() {
|
||||
return selections[currentSelection].value;
|
||||
}
|
||||
|
||||
void ModeSelectorCanvas::setToggleMode(bool toggleMode) {
|
||||
this->toggleMode = toggleMode;
|
||||
void ModeSelectorCanvas::setToggleMode(bool toggleMode_in) {
|
||||
toggleMode = toggleMode_in;
|
||||
}
|
||||
|
||||
bool ModeSelectorCanvas::modeChanged() {
|
||||
bool ModeSelectorCanvas::modeChanged() const {
|
||||
return inputChanged;
|
||||
}
|
||||
|
||||
@ -213,12 +211,12 @@ void ModeSelectorCanvas::clearModeChanged() {
|
||||
inputChanged = false;
|
||||
}
|
||||
|
||||
void ModeSelectorCanvas::setPadding(float padX, float padY) {
|
||||
this->padX = padX;
|
||||
this->padY = padY;
|
||||
void ModeSelectorCanvas::setPadding(float padX_in, float padY_in) {
|
||||
padX = padX_in;
|
||||
padY = padY_in;
|
||||
}
|
||||
|
||||
void ModeSelectorCanvas::setHighlightColor(RGBA4f hc) {
|
||||
this->highlightColor = hc;
|
||||
this->highlightOverride = true;
|
||||
void ModeSelectorCanvas::setHighlightColor(const RGBA4f& hc) {
|
||||
highlightColor = hc;
|
||||
highlightOverride = true;
|
||||
}
|
||||
|
@ -28,25 +28,25 @@ public:
|
||||
class ModeSelectorCanvas: public InteractiveCanvas {
|
||||
public:
|
||||
ModeSelectorCanvas(wxWindow *parent, const wxGLAttributes& dispAttrs);
|
||||
~ModeSelectorCanvas();
|
||||
~ModeSelectorCanvas() override;
|
||||
|
||||
int getHoveredSelection();
|
||||
void setHelpTip(std::string tip);
|
||||
|
||||
void addChoice(int value, std::string label);
|
||||
void addChoice(std::string label);
|
||||
void setSelection(std::string label);
|
||||
void setSelection(const std::string& label);
|
||||
std::string getSelectionLabel();
|
||||
void setSelection(int value);
|
||||
int getSelection();
|
||||
|
||||
void setToggleMode(bool toggleMode);
|
||||
void setToggleMode(bool toggleMode_in);
|
||||
|
||||
bool modeChanged();
|
||||
bool modeChanged() const;
|
||||
void clearModeChanged();
|
||||
|
||||
void setPadding(float padX, float padY);
|
||||
void setHighlightColor(RGBA4f hc);
|
||||
void setPadding(float padX_in, float padY_in);
|
||||
void setHighlightColor(const RGBA4f& hc);
|
||||
|
||||
private:
|
||||
void setNumChoices(int numChoices_in);
|
||||
|
@ -25,7 +25,7 @@ void ModeSelectorContext::DrawBegin() {
|
||||
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];
|
||||
glGetIntegerv( GL_VIEWPORT, vp);
|
||||
|
||||
|
@ -6,8 +6,6 @@
|
||||
#include "PrimaryGLContext.h"
|
||||
#include "Gradient.h"
|
||||
|
||||
#define NUM_WATERFALL_LINES 512
|
||||
|
||||
class ModeSelectorCanvas;
|
||||
|
||||
class ModeSelectorContext: public PrimaryGLContext {
|
||||
@ -15,6 +13,6 @@ public:
|
||||
ModeSelectorContext(ModeSelectorCanvas *canvas, wxGLContext *sharedContext, wxGLContextAttrs *ctxAttrs);
|
||||
|
||||
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();
|
||||
};
|
||||
|
@ -14,13 +14,10 @@
|
||||
#endif
|
||||
|
||||
#include "CubicSDR.h"
|
||||
#include "CubicSDRDefs.h"
|
||||
#include "AppFrame.h"
|
||||
#include <algorithm>
|
||||
|
||||
wxString PrimaryGLContext::glGetwxString(GLenum name) {
|
||||
const GLubyte *v = glGetString(name);
|
||||
if (v == 0) {
|
||||
if (v == nullptr) {
|
||||
// The error is not important. It is GL_INVALID_ENUM.
|
||||
// We just want to clear the error stack.
|
||||
glGetError();
|
||||
@ -65,7 +62,7 @@ PrimaryGLContext::PrimaryGLContext(wxGLCanvas *canvas, wxGLContext *sharedContex
|
||||
//#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) {
|
||||
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) {
|
||||
srate = wxGetApp().getSampleRate();
|
||||
}
|
||||
@ -310,7 +307,7 @@ void PrimaryGLContext::DrawFreqBwInfo(long long freq, int bw, RGBA4f color, long
|
||||
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) {
|
||||
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);
|
||||
}
|
||||
|
||||
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();
|
||||
|
||||
@ -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) {
|
||||
float temp = uxPos2;
|
||||
uxPos2=uxPos1;
|
||||
@ -531,6 +528,6 @@ void PrimaryGLContext::EndDraw() {
|
||||
// CheckGLError();
|
||||
}
|
||||
|
||||
void PrimaryGLContext::setHoverAlpha(float hoverAlpha) {
|
||||
this->hoverAlpha = hoverAlpha;
|
||||
void PrimaryGLContext::setHoverAlpha(float hoverAlpha_in) {
|
||||
hoverAlpha = hoverAlpha_in;
|
||||
}
|
||||
|
@ -24,14 +24,14 @@ public:
|
||||
void BeginDraw(float r, float g, float b);
|
||||
void EndDraw();
|
||||
|
||||
void DrawFreqSelector(float uxPos, RGBA4f color, float w = 0, long long center_freq = -1, long long srate = 0);
|
||||
void DrawRangeSelector(float uxPos1, float uxPos2, RGBA4f color);
|
||||
void DrawDemod(DemodulatorInstancePtr demod, RGBA4f color, 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, const RGBA4f& color);
|
||||
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 DrawFreqBwInfo(long long freq, int bw, RGBA4f color, long long center_freq = - 1, long long srate = 0, bool stack = false, 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, 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:
|
||||
float hoverAlpha;
|
||||
|
@ -14,8 +14,6 @@
|
||||
#endif
|
||||
|
||||
#include "CubicSDR.h"
|
||||
#include "CubicSDRDefs.h"
|
||||
#include "AppFrame.h"
|
||||
#include <algorithm>
|
||||
#include <cmath>
|
||||
|
||||
@ -31,7 +29,7 @@ EVT_LEAVE_WINDOW(ScopeCanvas::OnMouseLeftWindow)
|
||||
EVT_ENTER_WINDOW(ScopeCanvas::OnMouseEnterWindow)
|
||||
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());
|
||||
inputData->set_max_num_items(2);
|
||||
@ -51,9 +49,7 @@ ScopeCanvas::ScopeCanvas(wxWindow *parent, const wxGLAttributes& dispAttrs) : In
|
||||
spectrumPanel.setUseDBOffset(false);
|
||||
}
|
||||
|
||||
ScopeCanvas::~ScopeCanvas() {
|
||||
|
||||
}
|
||||
ScopeCanvas::~ScopeCanvas() = default;
|
||||
|
||||
bool ScopeCanvas::scopeVisible() {
|
||||
float panelInterval = (2.0 + panelSpacing);
|
||||
@ -84,11 +80,11 @@ void ScopeCanvas::setDeviceName(std::string device_name) {
|
||||
deviceName.append(" ");
|
||||
}
|
||||
|
||||
void ScopeCanvas::setPPMMode(bool ppmMode) {
|
||||
this->ppmMode = ppmMode;
|
||||
void ScopeCanvas::setPPMMode(bool ppmMode_in) {
|
||||
ppmMode = ppmMode_in;
|
||||
}
|
||||
|
||||
bool ScopeCanvas::getPPMMode() {
|
||||
bool ScopeCanvas::getPPMMode() const {
|
||||
return ppmMode;
|
||||
}
|
||||
|
||||
@ -96,7 +92,7 @@ void ScopeCanvas::setShowDb(bool show) {
|
||||
this->showDb = show;
|
||||
}
|
||||
|
||||
bool ScopeCanvas::getShowDb() {
|
||||
bool ScopeCanvas::getShowDb() const {
|
||||
return showDb;
|
||||
}
|
||||
|
||||
@ -110,12 +106,12 @@ void ScopeCanvas::OnPaint(wxPaintEvent& WXUNUSED(event)) {
|
||||
|
||||
if (!avData->spectrum) {
|
||||
scopePanel.setMode(avData->mode);
|
||||
if (avData->waveform_points.size()) {
|
||||
if (!avData->waveform_points.empty()) {
|
||||
scopePanel.setPoints(avData->waveform_points);
|
||||
}
|
||||
|
||||
} else {
|
||||
if (avData->waveform_points.size()) {
|
||||
if (!avData->waveform_points.empty()) {
|
||||
spectrumPanel.setPoints(avData->waveform_points);
|
||||
spectrumPanel.setFloorValue(avData->fft_floor);
|
||||
spectrumPanel.setCeilValue(avData->fft_ceil);
|
||||
|
@ -32,11 +32,11 @@ public:
|
||||
void OnKeyUp(wxKeyEvent& event);
|
||||
|
||||
void setDeviceName(std::string device_name);
|
||||
void setPPMMode(bool ppmMode);
|
||||
bool getPPMMode();
|
||||
void setPPMMode(bool ppmMode_in);
|
||||
bool getPPMMode() const;
|
||||
|
||||
void setShowDb(bool showDb);
|
||||
bool getShowDb();
|
||||
bool getShowDb() const;
|
||||
|
||||
bool scopeVisible();
|
||||
bool spectrumVisible();
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
void ScopeContext::DrawDeviceName(std::string deviceName) {
|
||||
void ScopeContext::DrawDeviceName(const std::string& deviceName) {
|
||||
GLint vp[4];
|
||||
glGetIntegerv(GL_VIEWPORT, vp);
|
||||
float viewHeight = (float) vp[3];
|
||||
@ -56,7 +56,7 @@ void ScopeContext::DrawDeviceName(std::string deviceName) {
|
||||
|
||||
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() {
|
||||
|
@ -6,8 +6,6 @@
|
||||
#include "PrimaryGLContext.h"
|
||||
#include "Gradient.h"
|
||||
|
||||
#define NUM_WATERFALL_LINES 512
|
||||
|
||||
class ScopeCanvas;
|
||||
|
||||
class ScopeContext: public PrimaryGLContext {
|
||||
@ -16,7 +14,7 @@ public:
|
||||
|
||||
void DrawBegin(bool clear=true);
|
||||
void DrawTunerTitles(bool ppmMode=false);
|
||||
void DrawDeviceName(std::string deviceName);
|
||||
void DrawDeviceName(const std::string& deviceName);
|
||||
void DrawDivider();
|
||||
void DrawEnd();
|
||||
|
||||
|
@ -17,7 +17,6 @@
|
||||
#include "CubicSDRDefs.h"
|
||||
#include "AppFrame.h"
|
||||
#include <algorithm>
|
||||
#include <wx/numformatter.h>
|
||||
#include "WaterfallCanvas.h"
|
||||
|
||||
wxBEGIN_EVENT_TABLE(SpectrumCanvas, wxGLCanvas) EVT_PAINT(SpectrumCanvas::OnPaint)
|
||||
@ -33,7 +32,7 @@ EVT_RIGHT_UP(SpectrumCanvas::OnMouseRightReleased)
|
||||
wxEND_EVENT_TABLE()
|
||||
|
||||
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());
|
||||
|
||||
@ -46,9 +45,7 @@ SpectrumCanvas::SpectrumCanvas(wxWindow *parent, const wxGLAttributes& dispAttrs
|
||||
bwChange = 0.0;
|
||||
}
|
||||
|
||||
SpectrumCanvas::~SpectrumCanvas() {
|
||||
|
||||
}
|
||||
SpectrumCanvas::~SpectrumCanvas() = default;
|
||||
|
||||
void SpectrumCanvas::OnPaint(wxPaintEvent& WXUNUSED(event)) {
|
||||
// wxPaintDC dc(this);
|
||||
@ -93,11 +90,11 @@ void SpectrumCanvas::OnPaint(wxPaintEvent& WXUNUSED(event)) {
|
||||
auto demods = wxGetApp().getDemodMgr().getDemodulators();
|
||||
auto activeDemodulator = wxGetApp().getDemodMgr().getActiveContextModem();
|
||||
|
||||
for (int i = 0, iMax = demods.size(); i < iMax; i++) {
|
||||
if (!demods[i]->isActive()) {
|
||||
for (auto & demod : demods) {
|
||||
if (!demod->isActive()) {
|
||||
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) {
|
||||
|
@ -18,7 +18,7 @@ class WaterfallCanvas;
|
||||
class SpectrumCanvas: public InteractiveCanvas {
|
||||
public:
|
||||
SpectrumCanvas(wxWindow *parent, const wxGLAttributes& dispAttrs);
|
||||
~SpectrumCanvas();
|
||||
~SpectrumCanvas() override;
|
||||
|
||||
//This is public because it is indeed forwarded from
|
||||
//AppFrame::OnGlobalKeyDown, because global key handler intercepts
|
||||
@ -40,7 +40,7 @@ public:
|
||||
bool getUseDBOfs();
|
||||
|
||||
void setView(long long center_freq_in, int bandwidth_in);
|
||||
void disableView();
|
||||
void disableView() override;
|
||||
|
||||
void setScaleFactorEnabled(bool en);
|
||||
void setFFTSize(int fftSize);
|
||||
|
@ -56,9 +56,7 @@ TuningCanvas::TuningCanvas(wxWindow *parent, const wxGLAttributes& dispAttrs) :
|
||||
currentPPM = lastPPM = 0;
|
||||
}
|
||||
|
||||
TuningCanvas::~TuningCanvas() {
|
||||
|
||||
}
|
||||
TuningCanvas::~TuningCanvas() = default;
|
||||
|
||||
bool TuningCanvas::changed() {
|
||||
|
||||
@ -182,52 +180,52 @@ void TuningCanvas::StepTuner(ActiveState state, TuningDirection tuningDir, int d
|
||||
|
||||
auto activeDemod = wxGetApp().getDemodMgr().getCurrentModem();
|
||||
if (state == TUNING_HOVER_FREQ && activeDemod) {
|
||||
long long freq = activeDemod->getFrequency();
|
||||
long long diff = abs(wxGetApp().getFrequency() - freq);
|
||||
long long demod_freq = activeDemod->getFrequency();
|
||||
long long diff = abs(wxGetApp().getFrequency() - demod_freq);
|
||||
|
||||
if (zeroOut) { // Zero digits to right
|
||||
double intpart;
|
||||
modf(freq / (exp * 10), &intpart);
|
||||
freq = intpart * exp * 10;
|
||||
modf(demod_freq / (exp * 10), &intpart);
|
||||
demod_freq = intpart * exp * 10;
|
||||
} else if (preventCarry) { // Prevent digit from carrying
|
||||
bool carried = (long long)((freq) / (exp * 10)) != (long long)((freq + amount) / (exp * 10)) || (bottom && freq < exp);
|
||||
freq += carried?(9*-amount):amount;
|
||||
bool carried = (long long)((demod_freq) / (exp * 10)) != (long long)((demod_freq + amount) / (exp * 10)) || (bottom && demod_freq < exp);
|
||||
demod_freq += carried ? (9 * -amount) : amount;
|
||||
} else {
|
||||
freq += amount;
|
||||
demod_freq += amount;
|
||||
}
|
||||
|
||||
if (wxGetApp().getSampleRate() / 2 < diff) {
|
||||
wxGetApp().setFrequency(freq);
|
||||
wxGetApp().setFrequency(demod_freq);
|
||||
}
|
||||
|
||||
activeDemod->setTracking(true);
|
||||
activeDemod->setFollow(true);
|
||||
activeDemod->setFrequency(freq);
|
||||
activeDemod->setFrequency(demod_freq);
|
||||
if (activeDemod->isDeltaLock()) {
|
||||
activeDemod->setDeltaLockOfs(activeDemod->getFrequency() - wxGetApp().getFrequency());
|
||||
}
|
||||
activeDemod->updateLabel(freq);
|
||||
activeDemod->updateLabel(demod_freq);
|
||||
}
|
||||
|
||||
if (state == TUNING_HOVER_BW) {
|
||||
long bw = wxGetApp().getDemodMgr().getLastBandwidth();
|
||||
long nbw = wxGetApp().getDemodMgr().getLastBandwidth();
|
||||
|
||||
if (zeroOut) { // Zero digits to right
|
||||
double intpart;
|
||||
modf(bw / (exp * 10), &intpart);
|
||||
bw = intpart * exp * 10;
|
||||
modf(nbw / (exp * 10), &intpart);
|
||||
nbw = intpart * exp * 10;
|
||||
} else if (preventCarry) { // Prevent digit from carrying
|
||||
bool carried = (long)((bw) / (exp * 10)) != (long)((bw + amount) / (exp * 10)) || (bottom && bw < exp);
|
||||
bw += carried?(9*-amount):amount;
|
||||
bool carried = (long)((nbw) / (exp * 10)) != (long)((nbw + amount) / (exp * 10)) || (bottom && nbw < exp);
|
||||
nbw += carried ? (9 * -amount) : amount;
|
||||
} else {
|
||||
bw += amount;
|
||||
nbw += amount;
|
||||
}
|
||||
|
||||
if (bw > CHANNELIZER_RATE_MAX) {
|
||||
bw = CHANNELIZER_RATE_MAX;
|
||||
if (nbw > CHANNELIZER_RATE_MAX) {
|
||||
nbw = CHANNELIZER_RATE_MAX;
|
||||
}
|
||||
|
||||
wxGetApp().getDemodMgr().setLastBandwidth(bw);
|
||||
wxGetApp().getDemodMgr().setLastBandwidth(nbw);
|
||||
|
||||
if (activeDemod) {
|
||||
activeDemod->setBandwidth(wxGetApp().getDemodMgr().getLastBandwidth());
|
||||
@ -298,12 +296,10 @@ void TuningCanvas::OnIdle(wxIdleEvent & /* event */) {
|
||||
void TuningCanvas::OnMouseMoved(wxMouseEvent& event) {
|
||||
InteractiveCanvas::OnMouseMoved(event);
|
||||
|
||||
int index = 0;
|
||||
|
||||
top = 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) {
|
||||
hoverIndex = index;
|
||||
hoverState = altDown?TUNING_HOVER_PPM:TUNING_HOVER_FREQ;
|
||||
|
@ -24,7 +24,7 @@ public:
|
||||
TUNING_DIRECTION_DOWN, TUNING_DIRECTION_UP
|
||||
};
|
||||
TuningCanvas(wxWindow *parent, const wxGLAttributes& dispAttrs);
|
||||
~TuningCanvas();
|
||||
~TuningCanvas() override;
|
||||
|
||||
void setHelpTip(std::string tip);
|
||||
bool changed();
|
||||
|
@ -9,11 +9,11 @@
|
||||
// http://stackoverflow.com/questions/7276826/c-format-number-with-commas
|
||||
class comma_numpunct: public std::numpunct<char> {
|
||||
protected:
|
||||
virtual char do_thousands_sep() const {
|
||||
char do_thousands_sep() const override {
|
||||
return ',';
|
||||
}
|
||||
|
||||
virtual std::string do_grouping() const {
|
||||
std::string do_grouping() const override {
|
||||
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];
|
||||
glGetIntegerv( GL_VIEWPORT, vp);
|
||||
|
||||
@ -160,7 +160,7 @@ int TuningContext::GetTunerDigitIndex(float mPos, int count, float displayPos, f
|
||||
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) {
|
||||
float ofs = (displayWidth / (float) count);
|
||||
float p2 = displayPos + ofs * (float) (count - start + 1);
|
||||
|
@ -6,8 +6,6 @@
|
||||
#include "PrimaryGLContext.h"
|
||||
#include "Gradient.h"
|
||||
|
||||
#define NUM_WATERFALL_LINES 512
|
||||
|
||||
class TuningCanvas;
|
||||
|
||||
class TuningContext: public PrimaryGLContext {
|
||||
@ -17,9 +15,9 @@ public:
|
||||
void DrawBegin();
|
||||
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 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);
|
||||
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 DrawEnd();
|
||||
|
@ -53,8 +53,7 @@ WaterfallCanvas::WaterfallCanvas(wxWindow *parent, const wxGLAttributes& dispAtt
|
||||
fft_size_changed.store(false);
|
||||
}
|
||||
|
||||
WaterfallCanvas::~WaterfallCanvas() {
|
||||
}
|
||||
WaterfallCanvas::~WaterfallCanvas() = default;
|
||||
|
||||
void WaterfallCanvas::setup(unsigned int fft_size_in, int waterfall_lines_in) {
|
||||
if (fft_size == fft_size_in && waterfall_lines_in == waterfall_lines) {
|
||||
@ -333,23 +332,23 @@ void WaterfallCanvas::OnPaint(wxPaintEvent& WXUNUSED(event)) {
|
||||
|
||||
glContext->setHoverAlpha(0);
|
||||
|
||||
for (int i = 0, iMax = demods.size(); i < iMax; i++) {
|
||||
if (!demods[i]->isActive()) {
|
||||
for (auto & demod : demods) {
|
||||
if (!demod->isActive()) {
|
||||
continue;
|
||||
}
|
||||
if (activeDemodulator == demods[i] || lastActiveDemodulator == demods[i]) {
|
||||
if (activeDemodulator == demod || lastActiveDemodulator == demod) {
|
||||
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++) {
|
||||
demods[i]->getVisualCue()->step();
|
||||
for (auto & demod : demods) {
|
||||
demod->getVisualCue()->step();
|
||||
|
||||
int squelchBreak = demods[i]->getVisualCue()->getSquelchBreak();
|
||||
int squelchBreak = demod->getVisualCue()->getSquelchBreak();
|
||||
if (squelchBreak) {
|
||||
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()) {
|
||||
wxGetApp().setFrequency(wxGetApp().getDemodMgr().getActiveContextModem()->getFrequency());
|
||||
} else if (mouseTracker.mouseInView()) {
|
||||
long long freq = getFrequencyAt(mouseTracker.getMouseX());
|
||||
long long nfreq = getFrequencyAt(mouseTracker.getMouseX());
|
||||
|
||||
int snap = wxGetApp().getFrequencySnap();
|
||||
|
||||
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
|
||||
if (wxGetApp().rigIsActive() && (!wxGetApp().getRigThread()->getControlMode() || wxGetApp().getRigThread()->getCenterLock())) {
|
||||
@ -504,13 +503,12 @@ void WaterfallCanvas::updateHoverState() {
|
||||
} else {
|
||||
setStatusText("Click and drag to set the current demodulator range.");
|
||||
}
|
||||
} else if (demodsHover.size() && !shiftDown) {
|
||||
} else if (!demodsHover.empty() && !shiftDown) {
|
||||
long near_dist = getBandwidth();
|
||||
|
||||
DemodulatorInstancePtr activeDemodulator = nullptr;
|
||||
|
||||
for (int i = 0, iMax = demodsHover.size(); i < iMax; i++) {
|
||||
auto demod = demodsHover[i];
|
||||
for (auto demod : demodsHover) {
|
||||
long long freqDiff = demod->getFrequency() - freqPos;
|
||||
long halfBw = (demod->getBandwidth() / 2);
|
||||
long long currentBw = getBandwidth();
|
||||
@ -708,7 +706,7 @@ void WaterfallCanvas::OnMouseReleased(wxMouseEvent& event) {
|
||||
|
||||
|
||||
if (dragState == WF_DRAG_NONE) {
|
||||
if (!isNew && wxGetApp().getDemodMgr().getDemodulators().size()) {
|
||||
if (!isNew && !wxGetApp().getDemodMgr().getDemodulators().empty()) {
|
||||
mgr->updateLastState();
|
||||
demod = wxGetApp().getDemodMgr().getCurrentModem();
|
||||
} else {
|
||||
@ -809,7 +807,7 @@ void WaterfallCanvas::OnMouseReleased(wxMouseEvent& event) {
|
||||
}
|
||||
|
||||
|
||||
if (!isNew && wxGetApp().getDemodMgr().getDemodulators().size()) {
|
||||
if (!isNew && !wxGetApp().getDemodMgr().getDemodulators().empty()) {
|
||||
mgr->updateLastState();
|
||||
demod = wxGetApp().getDemodMgr().getCurrentModem();
|
||||
} else {
|
||||
|
@ -24,7 +24,7 @@ public:
|
||||
WaterfallCanvas(wxWindow *parent, const wxGLAttributes& dispAttrs);
|
||||
void setup(unsigned int fft_size_in, int waterfall_lines_in);
|
||||
void setFFTSize(unsigned int fft_size_in);
|
||||
~WaterfallCanvas();
|
||||
~WaterfallCanvas() override;
|
||||
|
||||
DragState getDragState();
|
||||
DragState getNextDragState();
|
||||
|
Loading…
Reference in New Issue
Block a user