Cleanup: scope, meter, spectrum and waterfall panels

This commit is contained in:
Charles J. Cliffe 2021-04-04 22:17:30 -04:00
parent 9e22a1314c
commit 0b9bcc5a46
8 changed files with 95 additions and 98 deletions

View File

@ -5,7 +5,7 @@
#include "ColorTheme.h"
MeterPanel::MeterPanel(std::string name, float low, float high, float current) {
MeterPanel::MeterPanel(const std::string& name, float low, float high, float current) {
this->name = name;
this->low = low;
this->high = high;
@ -35,7 +35,7 @@ MeterPanel::MeterPanel(std::string name, float low, float high, float current) {
highlightPanel.setBlend(GL_ONE, GL_ONE);
highlightPanel.visible = false;
c1 = RGBA4f(0.3f,0.3f,0.3f,1.0f);
c2 = RGBA4f(0.65f,0.65f,0.65f,1.0f);;
c2 = RGBA4f(0.65f,0.65f,0.65f,1.0f);
highlightPanel.setFillColor(c1, c2);
bgPanel.addChild(&highlightPanel);
@ -58,9 +58,7 @@ MeterPanel::MeterPanel(std::string name, float low, float high, float current) {
addChild(&valuePanel);
}
MeterPanel::~MeterPanel() {
}
MeterPanel::~MeterPanel() = default;
void MeterPanel::setName(std::string name_in) {
@ -71,17 +69,17 @@ std::string MeterPanel::getName() {
return name;
}
void MeterPanel::setRange(float low, float high) {
this->low = low;
this->high = high;
void MeterPanel::setRange(float low_in, float high_in) {
low = low_in;
high = high_in;
}
float MeterPanel::getLow() {
return this->low;
float MeterPanel::getLow() const {
return low;
}
float MeterPanel::getHigh() {
return this->high;
float MeterPanel::getHigh() const {
return high;
}
void MeterPanel::setValue(float value) {
@ -112,7 +110,7 @@ void MeterPanel::setHighlightVisible(bool vis) {
highlightPanel.visible = vis;
}
float MeterPanel::getValue() {
float MeterPanel::getValue() const {
return current;
}
@ -196,16 +194,16 @@ void MeterPanel::setValueLabel(std::string label) {
}
void MeterPanel::setPanelLevel(float setValue, GLPanel &panel) {
void MeterPanel::setPanelLevel(float setValue, GLPanel &panel) const {
float valueNorm = (setValue - low) / (high - low);
panel.setSize(1.0, valueNorm);
panel.setPosition(0.0, (-1.0+(valueNorm)));
}
bool MeterPanel::getChanged() {
bool MeterPanel::getChanged() const {
return changed;
}
void MeterPanel::setChanged(bool changed) {
this->changed = changed;
void MeterPanel::setChanged(bool changed_in) {
changed = changed_in;
}

View File

@ -8,26 +8,26 @@
class MeterPanel : public GLPanel {
public:
MeterPanel(std::string name, float low, float high, float current);
~MeterPanel();
MeterPanel(const std::string& name, float low, float high, float current);
~MeterPanel() override;
void setName(std::string name_in);
std::string getName();
void setRange(float low, float high);
float getLow();
float getHigh();
void setRange(float low_in, float high_in);
float getLow() const;
float getHigh() const;
void setValue(float value);
void setHighlight(float value);
void setHighlightVisible(bool vis);
float getValue();
float getValue() const;
bool isMeterHit(CubicVR::vec2 mousePoint);
float getMeterHitValue(CubicVR::vec2 mousePoint);
void setChanged(bool changed);
bool getChanged();
void setChanged(bool changed_in);
bool getChanged() const;
protected:
void drawPanelContents();
void drawPanelContents() override;
void setValueLabel(std::string label);
void setPanelLevel(float setValue, GLPanel &panel);
void setPanelLevel(float setValue, GLPanel &panel) const;
private:
std::string name;

View File

@ -15,16 +15,16 @@ ScopePanel::ScopePanel() : GLPanel(), scopeMode(SCOPE_MODE_Y) {
bgPanelStereo[1].setSize(1, 0.5);
}
void ScopePanel::setMode(ScopeMode scopeMode) {
this->scopeMode = scopeMode;
void ScopePanel::setMode(ScopeMode scopeMode_in) {
scopeMode = scopeMode_in;
}
ScopePanel::ScopeMode ScopePanel::getMode() {
return this->scopeMode;
}
void ScopePanel::setPoints(std::vector<float> &points) {
this->points.assign(points.begin(),points.end());
void ScopePanel::setPoints(std::vector<float> &points_in) {
points.assign(points_in.begin(), points_in.end());
}
void ScopePanel::drawPanelContents() {
@ -81,7 +81,7 @@ void ScopePanel::drawPanelContents() {
ThemeMgr::mgr.currentTheme->scopeLine.b * 0.15);
}
if (points.size()) {
if (!points.empty()) {
glEnable (GL_BLEND);
glEnable (GL_LINE_SMOOTH);
glHint(GL_LINE_SMOOTH_HINT, GL_NICEST);

View File

@ -12,12 +12,12 @@ public:
ScopePanel();
void setMode(ScopeMode scopeMode);
void setMode(ScopeMode scopeMode_in);
ScopeMode getMode();
void setPoints(std::vector<float> &points);
void setPoints(std::vector<float> &points_in);
protected:
void drawPanelContents();
void drawPanelContents() override;
private:
std::vector<float> points;

View File

@ -3,7 +3,6 @@
#include "SpectrumPanel.h"
#include <sstream>
#include <iostream>
#include <iomanip>
#include "CubicSDR.h"
@ -32,35 +31,35 @@ SpectrumPanel::SpectrumPanel() {
}
float SpectrumPanel::getFloorValue() {
float SpectrumPanel::getFloorValue() const {
return floorValue;
}
void SpectrumPanel::setFloorValue(float floorValue) {
this->floorValue = floorValue;
void SpectrumPanel::setFloorValue(float floorValue_in) {
floorValue = floorValue_in;
}
float SpectrumPanel::getCeilValue() {
float SpectrumPanel::getCeilValue() const {
return ceilValue;
}
void SpectrumPanel::setCeilValue(float ceilValue) {
this->ceilValue = ceilValue;
void SpectrumPanel::setCeilValue(float ceilValue_in) {
ceilValue = ceilValue_in;
}
void SpectrumPanel::setFreq(long long freq) {
this->freq = freq;
void SpectrumPanel::setFreq(long long freq_in) {
freq = freq_in;
}
long long SpectrumPanel::getFreq() {
long long SpectrumPanel::getFreq() const {
return freq;
}
void SpectrumPanel::setBandwidth(long long bandwidth) {
this->bandwidth = bandwidth;
void SpectrumPanel::setBandwidth(long long bandwidth_in) {
bandwidth = bandwidth_in;
}
long long SpectrumPanel::getBandwidth() {
long long SpectrumPanel::getBandwidth() const {
return bandwidth;
}
@ -68,13 +67,13 @@ void SpectrumPanel::setFFTSize(int fftSize_in) {
this->fftSize = fftSize_in;
}
int SpectrumPanel::getFFTSize() {
int SpectrumPanel::getFFTSize() const {
return fftSize;
}
void SpectrumPanel::setShowDb(bool showDb) {
this->showDb = showDb;
if (showDb) {
void SpectrumPanel::setShowDb(bool showDb_in) {
showDb = showDb_in;
if (showDb_in) {
addChild(&dbPanelCeil);
addChild(&dbPanelFloor);
} else {
@ -84,7 +83,7 @@ void SpectrumPanel::setShowDb(bool showDb) {
}
bool SpectrumPanel::getShowDb() {
bool SpectrumPanel::getShowDb() const {
return showDb;
}
@ -92,17 +91,17 @@ void SpectrumPanel::setUseDBOffset(bool useOfs) {
this->useDbOfs = useOfs;
}
bool SpectrumPanel::getUseDBOffset() {
bool SpectrumPanel::getUseDBOffset() const {
return useDbOfs;
}
void SpectrumPanel::setPoints(std::vector<float> &points) {
this->points.assign(points.begin(), points.end());
void SpectrumPanel::setPoints(std::vector<float> &points_in) {
points.assign(points_in.begin(), points_in.end());
}
void SpectrumPanel::setPeakPoints(std::vector<float> &points) {
this->peak_points.assign(points.begin(), points.end());
void SpectrumPanel::setPeakPoints(std::vector<float> &points_in) {
peak_points.assign(points_in.begin(), points_in.end());
}
@ -115,17 +114,17 @@ void SpectrumPanel::drawPanelContents() {
glLoadMatrixf((transform * (CubicVR::mat4::translate(-1.0f, -0.75f, 0.0f) * CubicVR::mat4::scale(2.0f, 1.5f, 1.0f))).to_ptr());
if (points.size()) {
if (!points.empty()) {
glBlendFunc(GL_SRC_ALPHA, GL_ONE);
double range = ceilValue-floorValue;
double ranges[3][4] = { { 90.0, 5000.0, 10.0, 100.0 }, { 20.0, 150.0, 10.0, 10.0 }, { -20.0, 30.0, 10.0, 1.0 } };
for (int i = 0; i < 3; i++) {
for (auto & i : ranges) {
double p = 0;
double rangeMin = ranges[i][0];
double rangeMax = ranges[i][1];
double rangeTrans = ranges[i][2];
double rangeStep = ranges[i][3];
double rangeMin = i[0];
double rangeMax = i[1];
double rangeTrans = i[2];
double rangeStep = i[3];
if (range >= rangeMin && range <= rangeMax) {
double a = 1.0;
@ -152,7 +151,7 @@ void SpectrumPanel::drawPanelContents() {
glEnableClientState(GL_VERTEX_ARRAY);
glVertexPointer(2, GL_FLOAT, 0, &points[0]);
glDrawArrays(GL_LINE_STRIP, 0, points.size() / 2);
if (peak_points.size()) {
if (!peak_points.empty()) {
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glColor4f(0, 1.0, 0, 0.5);
glVertexPointer(2, GL_FLOAT, 0, &peak_points[0]);

View File

@ -9,32 +9,32 @@ class SpectrumPanel : public GLPanel {
public:
SpectrumPanel();
void setPoints(std::vector<float> &points);
void setPeakPoints(std::vector<float> &points);
void setPoints(std::vector<float> &points_in);
void setPeakPoints(std::vector<float> &points_in);
float getFloorValue();
void setFloorValue(float floorValue);
float getFloorValue() const;
void setFloorValue(float floorValue_in);
float getCeilValue();
void setCeilValue(float ceilValue);
float getCeilValue() const;
void setCeilValue(float ceilValue_in);
void setFreq(long long freq);
long long getFreq();
void setFreq(long long freq_in);
long long getFreq() const;
void setBandwidth(long long bandwidth);
long long getBandwidth();
void setBandwidth(long long bandwidth_in);
long long getBandwidth() const;
void setFFTSize(int fftSize_in);
int getFFTSize();
int getFFTSize() const;
void setShowDb(bool showDb);
bool getShowDb();
void setShowDb(bool showDb_in);
bool getShowDb() const;
void setUseDBOffset(bool useOfs);
bool getUseDBOffset();
bool getUseDBOffset() const;
protected:
void drawPanelContents();
void drawPanelContents() override;
private:
float floorValue, ceilValue;

View File

@ -3,10 +3,10 @@
#include "WaterfallPanel.h"
WaterfallPanel::WaterfallPanel() : GLPanel(), fft_size(0), waterfall_lines(0), waterfall_slice(NULL), activeTheme(NULL) {
WaterfallPanel::WaterfallPanel() : GLPanel(), fft_size(0), waterfall_lines(0), waterfall_slice(nullptr), activeTheme(nullptr) {
setFillColor(RGBA4f(0,0,0));
for (int i = 0; i < 2; i++) {
waterfall[i] = 0;
for (unsigned int & i : waterfall) {
i = 0;
}
}
@ -26,8 +26,8 @@ void WaterfallPanel::setup(unsigned int fft_size_in, int num_waterfall_lines_in)
void WaterfallPanel::refreshTheme() {
glEnable (GL_TEXTURE_2D);
for (int i = 0; i < 2; i++) {
glBindTexture(GL_TEXTURE_2D, waterfall[i]);
for (unsigned int i : waterfall) {
glBindTexture(GL_TEXTURE_2D, i);
glPixelTransferi(GL_MAP_COLOR, GL_TRUE);
glPixelMapfv(GL_PIXEL_MAP_I_TO_R, 256, &(ThemeMgr::mgr.currentTheme->waterfallGradient.getRed())[0]);
@ -36,15 +36,15 @@ void WaterfallPanel::refreshTheme() {
}
}
void WaterfallPanel::setPoints(std::vector<float> &points) {
size_t halfPts = points.size()/2;
void WaterfallPanel::setPoints(std::vector<float> &points_in) {
size_t halfPts = points_in.size() / 2;
if (halfPts == fft_size) {
for (unsigned int i = 0; i < fft_size; i++) {
this->points[i] = points[i*2+1];
points[i] = points_in[i * 2 + 1];
}
} else {
this->points.assign(points.begin(), points.end());
points.assign(points_in.begin(), points_in.end());
}
}
@ -61,9 +61,9 @@ void WaterfallPanel::step() {
return;
}
if (points.size() && points.size() == fft_size) {
if (!points.empty() && points.size() == fft_size) {
for (int j = 0; j < 2; j++) {
for (int i = 0, iMax = half_fft_size; i < iMax; i++) {
for (unsigned int i = 0, iMax = half_fft_size; i < iMax; i++) {
float v = points[j * half_fft_size + i];
float wv = v < 0 ? 0 : (v > 0.99 ? 0.99 : v);
@ -83,7 +83,7 @@ void WaterfallPanel::step() {
}
void WaterfallPanel::update() {
int half_fft_size = fft_size / 2;
unsigned int half_fft_size = fft_size / 2;
if (!bufferInitialized.load()) {
return;
@ -110,8 +110,8 @@ void WaterfallPanel::update() {
waterfall_tex = new unsigned char[half_fft_size * waterfall_lines];
memset(waterfall_tex, 0, half_fft_size * waterfall_lines);
for (int i = 0; i < 2; i++) {
glBindTexture(GL_TEXTURE_2D, waterfall[i]);
for (unsigned int i : waterfall) {
glBindTexture(GL_TEXTURE_2D, i);
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
@ -136,7 +136,7 @@ void WaterfallPanel::update() {
}
}
int run_ofs = 0;
unsigned int run_ofs = 0;
while (lines_buffered.load()) {
int run_lines = lines_buffered.load();
if (run_lines > waterfall_ofs[0]) {
@ -163,7 +163,7 @@ void WaterfallPanel::drawPanelContents() {
return;
}
int half_fft_size = fft_size / 2;
unsigned int half_fft_size = fft_size / 2;
glLoadMatrixf(transform.to_ptr());

View File

@ -11,12 +11,12 @@ public:
WaterfallPanel();
void setup(unsigned int fft_size_in, int num_waterfall_lines_in);
void refreshTheme();
void setPoints(std::vector<float> &points);
void setPoints(std::vector<float> &points_in);
void step();
void update();
protected:
void drawPanelContents();
void drawPanelContents() override;
private:
std::vector<float> points;