mirror of
https://github.com/cjcliffe/CubicSDR.git
synced 2024-11-23 04:08:36 -05:00
Merge pull request #28 from cjcliffe/color-themes
Some basic color themes and selector
This commit is contained in:
commit
d2673185c6
@ -158,6 +158,20 @@ AppFrame::AppFrame() :
|
|||||||
|
|
||||||
menuBar->Append(menu, wxT("Active Demodulator &Output"));
|
menuBar->Append(menu, wxT("Active Demodulator &Output"));
|
||||||
|
|
||||||
|
|
||||||
|
menu = new wxMenu;
|
||||||
|
|
||||||
|
menu->Append(wxID_THEME_DEFAULT, "Default");
|
||||||
|
menu->Append(wxID_THEME_RADAR, "RADAR");
|
||||||
|
menu->Append(wxID_THEME_BW, "Black & White");
|
||||||
|
menu->Append(wxID_THEME_SHARP, "Sharp");
|
||||||
|
menu->Append(wxID_THEME_RAD, "Rad");
|
||||||
|
menu->Append(wxID_THEME_TOUCH, "Touch");
|
||||||
|
menu->Append(wxID_THEME_HD, "HD");
|
||||||
|
|
||||||
|
menuBar->Append(menu, wxT("&Color Scheme"));
|
||||||
|
|
||||||
|
|
||||||
SetMenuBar(menuBar);
|
SetMenuBar(menuBar);
|
||||||
|
|
||||||
CreateStatusBar();
|
CreateStatusBar();
|
||||||
@ -226,6 +240,27 @@ void AppFrame::OnMenu(wxCommandEvent& event) {
|
|||||||
currentSessionFile = "";
|
currentSessionFile = "";
|
||||||
} else if (event.GetId() == wxID_EXIT) {
|
} else if (event.GetId() == wxID_EXIT) {
|
||||||
Close(false);
|
Close(false);
|
||||||
|
} else if (event.GetId() == wxID_THEME_DEFAULT) {
|
||||||
|
waterfallCanvas->setTheme(COLOR_THEME_DEFAULT);
|
||||||
|
demodWaterfallCanvas->setTheme(COLOR_THEME_DEFAULT);
|
||||||
|
} else if (event.GetId() == wxID_THEME_SHARP) {
|
||||||
|
waterfallCanvas->setTheme(COLOR_THEME_SHARP);
|
||||||
|
demodWaterfallCanvas->setTheme(COLOR_THEME_SHARP);
|
||||||
|
} else if (event.GetId() == wxID_THEME_BW) {
|
||||||
|
waterfallCanvas->setTheme(COLOR_THEME_BW);
|
||||||
|
demodWaterfallCanvas->setTheme(COLOR_THEME_BW);
|
||||||
|
} else if (event.GetId() == wxID_THEME_RAD) {
|
||||||
|
waterfallCanvas->setTheme(COLOR_THEME_RAD);
|
||||||
|
demodWaterfallCanvas->setTheme(COLOR_THEME_RAD);
|
||||||
|
} else if (event.GetId() == wxID_THEME_TOUCH) {
|
||||||
|
waterfallCanvas->setTheme(COLOR_THEME_TOUCH);
|
||||||
|
demodWaterfallCanvas->setTheme(COLOR_THEME_TOUCH);
|
||||||
|
} else if (event.GetId() == wxID_THEME_HD) {
|
||||||
|
waterfallCanvas->setTheme(COLOR_THEME_HD);
|
||||||
|
demodWaterfallCanvas->setTheme(COLOR_THEME_HD);
|
||||||
|
} else if (event.GetId() == wxID_THEME_RADAR) {
|
||||||
|
waterfallCanvas->setTheme(COLOR_THEME_RADAR);
|
||||||
|
demodWaterfallCanvas->setTheme(COLOR_THEME_RADAR);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -16,6 +16,14 @@
|
|||||||
#define wxID_SET_FREQ_OFFSET 2001
|
#define wxID_SET_FREQ_OFFSET 2001
|
||||||
#define wxID_RESET 2002
|
#define wxID_RESET 2002
|
||||||
|
|
||||||
|
#define wxID_THEME_DEFAULT 2100
|
||||||
|
#define wxID_THEME_SHARP 2101
|
||||||
|
#define wxID_THEME_BW 2102
|
||||||
|
#define wxID_THEME_RAD 2103
|
||||||
|
#define wxID_THEME_TOUCH 2104
|
||||||
|
#define wxID_THEME_HD 2105
|
||||||
|
#define wxID_THEME_RADAR 2106
|
||||||
|
|
||||||
// Define a new frame type
|
// Define a new frame type
|
||||||
class AppFrame: public wxFrame {
|
class AppFrame: public wxFrame {
|
||||||
public:
|
public:
|
||||||
|
@ -183,7 +183,7 @@ void DemodulatorInstance::squelchAuto() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool DemodulatorInstance::isSquelchEnabled() {
|
bool DemodulatorInstance::isSquelchEnabled() {
|
||||||
return squelch;
|
return (demodulatorThread->getSquelchLevel() != 0.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DemodulatorInstance::setSquelchEnabled(bool state) {
|
void DemodulatorInstance::setSquelchEnabled(bool state) {
|
||||||
|
@ -29,8 +29,8 @@ void Gradient::generate(unsigned int len) {
|
|||||||
b_val.resize(len);
|
b_val.resize(len);
|
||||||
|
|
||||||
for (unsigned int j = 0, jMax = colors.size() - 1; j < jMax; j++) {
|
for (unsigned int j = 0, jMax = colors.size() - 1; j < jMax; j++) {
|
||||||
if (chunk_size * (jMax + 1) < len && j == jMax - 1) {
|
if ((chunk_size * (jMax)) < len && (j == jMax - 1)) {
|
||||||
chunk_size += len - chunk_size * (jMax + 1);
|
chunk_size += len - chunk_size * (jMax);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (unsigned int i = 0; i < chunk_size; i++) {
|
for (unsigned int i = 0; i < chunk_size; i++) {
|
||||||
|
@ -36,7 +36,7 @@ wxEND_EVENT_TABLE()
|
|||||||
WaterfallCanvas::WaterfallCanvas(wxWindow *parent, int *attribList) :
|
WaterfallCanvas::WaterfallCanvas(wxWindow *parent, int *attribList) :
|
||||||
InteractiveCanvas(parent, attribList), spectrumCanvas(NULL), dragState(WF_DRAG_NONE), nextDragState(WF_DRAG_NONE), fft_size(0), waterfall_lines(
|
InteractiveCanvas(parent, attribList), spectrumCanvas(NULL), dragState(WF_DRAG_NONE), nextDragState(WF_DRAG_NONE), fft_size(0), waterfall_lines(
|
||||||
0), plan(
|
0), plan(
|
||||||
NULL), in(NULL), out(NULL), resampler(NULL), resamplerRatio(0), lastInputBandwidth(0), zoom(1), mouseZoom(1) {
|
NULL), in(NULL), out(NULL), resampler(NULL), resamplerRatio(0), lastInputBandwidth(0), zoom(1), mouseZoom(1), theme(0) {
|
||||||
|
|
||||||
glContext = new WaterfallContext(this, &wxGetApp().GetContext(this));
|
glContext = new WaterfallContext(this, &wxGetApp().GetContext(this));
|
||||||
|
|
||||||
@ -95,6 +95,11 @@ void WaterfallCanvas::OnPaint(wxPaintEvent& WXUNUSED(event)) {
|
|||||||
glContext->SetCurrent(*this);
|
glContext->SetCurrent(*this);
|
||||||
glViewport(0, 0, ClientSize.x, ClientSize.y);
|
glViewport(0, 0, ClientSize.x, ClientSize.y);
|
||||||
|
|
||||||
|
if (theme != glContext->getTheme()) {
|
||||||
|
glContext->setTheme(theme);
|
||||||
|
theme = glContext->getTheme();
|
||||||
|
}
|
||||||
|
|
||||||
glContext->BeginDraw();
|
glContext->BeginDraw();
|
||||||
glContext->Draw(spectrum_points);
|
glContext->Draw(spectrum_points);
|
||||||
|
|
||||||
@ -824,3 +829,11 @@ void WaterfallCanvas::OnMouseRightReleased(wxMouseEvent& event) {
|
|||||||
mouseTracker.setHorizDragLock(false);
|
mouseTracker.setHorizDragLock(false);
|
||||||
mouseZoom = 1.0;
|
mouseZoom = 1.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void WaterfallCanvas::setTheme(int theme_id) {
|
||||||
|
theme = theme_id;
|
||||||
|
}
|
||||||
|
|
||||||
|
int WaterfallCanvas::getTheme() {
|
||||||
|
return glContext->getTheme();
|
||||||
|
}
|
||||||
|
@ -29,6 +29,8 @@ public:
|
|||||||
DragState getNextDragState();
|
DragState getNextDragState();
|
||||||
|
|
||||||
void attachSpectrumCanvas(SpectrumCanvas *canvas_in);
|
void attachSpectrumCanvas(SpectrumCanvas *canvas_in);
|
||||||
|
void setTheme(int theme_id);
|
||||||
|
int getTheme();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void OnPaint(wxPaintEvent& event);
|
void OnPaint(wxPaintEvent& event);
|
||||||
@ -75,6 +77,8 @@ private:
|
|||||||
int lastInputBandwidth;
|
int lastInputBandwidth;
|
||||||
float mouseZoom, zoom;
|
float mouseZoom, zoom;
|
||||||
|
|
||||||
|
int theme;
|
||||||
|
|
||||||
std::vector<liquid_float_complex> shiftBuffer;
|
std::vector<liquid_float_complex> shiftBuffer;
|
||||||
std::vector<liquid_float_complex> resampleBuffer;
|
std::vector<liquid_float_complex> resampleBuffer;
|
||||||
// event table
|
// event table
|
||||||
|
@ -3,14 +3,83 @@
|
|||||||
#include "CubicSDR.h"
|
#include "CubicSDR.h"
|
||||||
|
|
||||||
WaterfallContext::WaterfallContext(WaterfallCanvas *canvas, wxGLContext *sharedContext) :
|
WaterfallContext::WaterfallContext(WaterfallCanvas *canvas, wxGLContext *sharedContext) :
|
||||||
PrimaryGLContext(canvas, sharedContext), waterfall(0), waterfall_tex(NULL) {
|
PrimaryGLContext(canvas, sharedContext), waterfall(0), waterfall_tex(NULL), waterfall_lines(0), fft_size(0), theme(COLOR_THEME_DEFAULT) {
|
||||||
grad.addColor(GradientColor(0, 0, 0));
|
Gradient *grad = new Gradient();
|
||||||
grad.addColor(GradientColor(0, 0, 1.0));
|
grad->addColor(GradientColor(0, 0, 0));
|
||||||
grad.addColor(GradientColor(0, 1.0, 0));
|
grad->addColor(GradientColor(0, 0, 1.0));
|
||||||
grad.addColor(GradientColor(1.0, 1.0, 0));
|
grad->addColor(GradientColor(0, 1.0, 0));
|
||||||
grad.addColor(GradientColor(1.0, 0.2, 0.0));
|
grad->addColor(GradientColor(1.0, 1.0, 0));
|
||||||
|
grad->addColor(GradientColor(1.0, 0.2, 0.0));
|
||||||
|
grad->generate(256);
|
||||||
|
gradients[COLOR_THEME_DEFAULT] = grad;
|
||||||
|
|
||||||
grad.generate(256);
|
grad = new Gradient();
|
||||||
|
grad->addColor(GradientColor(0, 0, 0));
|
||||||
|
grad->addColor(GradientColor(0.0, 0, 0.5));
|
||||||
|
grad->addColor(GradientColor(0.0, 0.0, 1.0));
|
||||||
|
grad->addColor(GradientColor(65.0 / 255.0, 161.0 / 255.0, 1.0));
|
||||||
|
grad->addColor(GradientColor(1.0, 1.0, 1.0));
|
||||||
|
grad->addColor(GradientColor(1.0, 1.0, 1.0));
|
||||||
|
grad->addColor(GradientColor(1.0, 1.0, 0.5));
|
||||||
|
grad->addColor(GradientColor(1.0, 1.0, 0.0));
|
||||||
|
grad->addColor(GradientColor(1.0, 0.5, 0.0));
|
||||||
|
grad->addColor(GradientColor(1.0, 0.25, 0.0));
|
||||||
|
grad->addColor(GradientColor(0.5, 0.1, 0.0));
|
||||||
|
grad->generate(256);
|
||||||
|
gradients[COLOR_THEME_SHARP] = grad;
|
||||||
|
|
||||||
|
grad = new Gradient();
|
||||||
|
grad->addColor(GradientColor(0, 0, 0));
|
||||||
|
grad->addColor(GradientColor(0.75, 0.75, 0.75));
|
||||||
|
grad->addColor(GradientColor(1.0, 1.0, 1.0));
|
||||||
|
grad->generate(256);
|
||||||
|
gradients[COLOR_THEME_BW] = grad;
|
||||||
|
|
||||||
|
grad = new Gradient();
|
||||||
|
grad->addColor(GradientColor(0, 0, 0.5));
|
||||||
|
grad->addColor(GradientColor(25.0/255.0, 154.0/255.0, 0.0));
|
||||||
|
grad->addColor(GradientColor(201.0/255.0, 115.0/255.0, 0.0));
|
||||||
|
grad->addColor(GradientColor(1.0, 40.0/255.0, 40.0/255.0));
|
||||||
|
grad->addColor(GradientColor(1.0, 1.0, 1.0));
|
||||||
|
grad->generate(256);
|
||||||
|
gradients[COLOR_THEME_RAD] = grad;
|
||||||
|
|
||||||
|
|
||||||
|
grad = new Gradient();
|
||||||
|
grad->addColor(GradientColor(0, 0, 0));
|
||||||
|
grad->addColor(GradientColor(55.0/255.0, 40.0/255.0, 55.0/255.0));
|
||||||
|
grad->addColor(GradientColor(60.0/255.0, 60.0/255.0, 90.0/255.0));
|
||||||
|
grad->addColor(GradientColor(0.0/255.0, 255.0/255.0, 255.0/255.0));
|
||||||
|
grad->addColor(GradientColor(10.0/255.0, 255.0/255.0, 85.0/255.0));
|
||||||
|
grad->addColor(GradientColor(255.0/255.0, 255.0/255.0, 75.0/255.0));
|
||||||
|
grad->addColor(GradientColor(255.0/255.0, 0.0/255.0, 0.0/255.0));
|
||||||
|
grad->addColor(GradientColor(255.0/255.0, 255.0/255.0, 255.0/255.0));
|
||||||
|
grad->generate(256);
|
||||||
|
gradients[COLOR_THEME_TOUCH] = grad;
|
||||||
|
|
||||||
|
|
||||||
|
grad = new Gradient();
|
||||||
|
grad->addColor(GradientColor(5.0/255.0, 5.0/255.0, 60.0/255.0));
|
||||||
|
grad->addColor(GradientColor(5.0/255.0, 20.0/255.0, 120.0/255.0));
|
||||||
|
grad->addColor(GradientColor(50.0/255.0, 100.0/255.0, 200.0/255.0));
|
||||||
|
grad->addColor(GradientColor(75.0/255.0, 190.0/255.0, 100.0/255.0));
|
||||||
|
grad->addColor(GradientColor(240.0/255.0, 55.0/255.0, 5.0/255.0));
|
||||||
|
grad->addColor(GradientColor(255.0/255.0, 55.0/255.0, 100.0/255.0));
|
||||||
|
grad->addColor(GradientColor(255.0/255.0, 235.0/255.0, 100.0/255.0));
|
||||||
|
grad->addColor(GradientColor(250.0/255.0, 250.0/255.0, 250.0/255.0));
|
||||||
|
grad->generate(256);
|
||||||
|
gradients[COLOR_THEME_HD] = grad;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
grad = new Gradient();
|
||||||
|
grad->addColor(GradientColor(5.0/255.0, 45.0/255.0, 10.0/255.0));
|
||||||
|
grad->addColor(GradientColor(30.0/255.0, 150.0/255.0, 40.0/255.0));
|
||||||
|
grad->addColor(GradientColor(40.0/255.0, 240.0/255.0, 60.0/255.0));
|
||||||
|
grad->addColor(GradientColor(250.0/255.0, 250.0/255.0, 250.0/255.0));
|
||||||
|
grad->generate(256);
|
||||||
|
gradients[COLOR_THEME_RADAR] = grad;
|
||||||
}
|
}
|
||||||
|
|
||||||
void WaterfallContext::Setup(int fft_size_in, int num_waterfall_lines_in) {
|
void WaterfallContext::Setup(int fft_size_in, int num_waterfall_lines_in) {
|
||||||
@ -26,7 +95,7 @@ void WaterfallContext::Setup(int fft_size_in, int num_waterfall_lines_in) {
|
|||||||
fft_size = fft_size_in;
|
fft_size = fft_size_in;
|
||||||
|
|
||||||
waterfall_tex = new unsigned char[fft_size * waterfall_lines];
|
waterfall_tex = new unsigned char[fft_size * waterfall_lines];
|
||||||
memset(waterfall_tex,0,fft_size * waterfall_lines);
|
memset(waterfall_tex, 0, fft_size * waterfall_lines);
|
||||||
|
|
||||||
glDisable(GL_CULL_FACE);
|
glDisable(GL_CULL_FACE);
|
||||||
glDisable(GL_DEPTH_TEST);
|
glDisable(GL_DEPTH_TEST);
|
||||||
@ -46,12 +115,30 @@ void WaterfallContext::Setup(int fft_size_in, int num_waterfall_lines_in) {
|
|||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||||
|
|
||||||
glPixelTransferi(GL_MAP_COLOR, GL_TRUE);
|
glPixelTransferi(GL_MAP_COLOR, GL_TRUE);
|
||||||
glPixelMapfv(GL_PIXEL_MAP_I_TO_R, 256, &(grad.getRed())[0]);
|
glPixelMapfv(GL_PIXEL_MAP_I_TO_R, 256, &(gradients[theme]->getRed())[0]);
|
||||||
glPixelMapfv(GL_PIXEL_MAP_I_TO_G, 256, &(grad.getGreen())[0]);
|
glPixelMapfv(GL_PIXEL_MAP_I_TO_G, 256, &(gradients[theme]->getGreen())[0]);
|
||||||
glPixelMapfv(GL_PIXEL_MAP_I_TO_B, 256, &(grad.getBlue())[0]);
|
glPixelMapfv(GL_PIXEL_MAP_I_TO_B, 256, &(gradients[theme]->getBlue())[0]);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void WaterfallContext::setTheme(int theme_id) {
|
||||||
|
glEnable(GL_TEXTURE_2D);
|
||||||
|
glBindTexture(GL_TEXTURE_2D, waterfall);
|
||||||
|
|
||||||
|
if (theme >= COLOR_THEME_MAX) {
|
||||||
|
theme = COLOR_THEME_MAX - 1;
|
||||||
|
}
|
||||||
|
if (theme < 0) {
|
||||||
|
theme = 0;
|
||||||
|
}
|
||||||
|
theme = theme_id;
|
||||||
|
|
||||||
|
glPixelTransferi(GL_MAP_COLOR, GL_TRUE);
|
||||||
|
glPixelMapfv(GL_PIXEL_MAP_I_TO_R, 256, &(gradients[theme]->getRed())[0]);
|
||||||
|
glPixelMapfv(GL_PIXEL_MAP_I_TO_G, 256, &(gradients[theme]->getGreen())[0]);
|
||||||
|
glPixelMapfv(GL_PIXEL_MAP_I_TO_B, 256, &(gradients[theme]->getBlue())[0]);
|
||||||
|
}
|
||||||
|
|
||||||
void WaterfallContext::Draw(std::vector<float> &points) {
|
void WaterfallContext::Draw(std::vector<float> &points) {
|
||||||
|
|
||||||
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL);
|
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL);
|
||||||
@ -65,8 +152,8 @@ void WaterfallContext::Draw(std::vector<float> &points) {
|
|||||||
float wv = v;
|
float wv = v;
|
||||||
if (wv < 0.0)
|
if (wv < 0.0)
|
||||||
wv = 0.0;
|
wv = 0.0;
|
||||||
if (wv > 1.0)
|
if (wv > 0.99)
|
||||||
wv = 1.0;
|
wv = 0.99;
|
||||||
waterfall_tex[i] = (unsigned char) floor(wv * 255.0);
|
waterfall_tex[i] = (unsigned char) floor(wv * 255.0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -94,3 +181,6 @@ void WaterfallContext::Draw(std::vector<float> &points) {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int WaterfallContext::getTheme() {
|
||||||
|
return theme;
|
||||||
|
}
|
||||||
|
@ -3,6 +3,16 @@
|
|||||||
#include "PrimaryGLContext.h"
|
#include "PrimaryGLContext.h"
|
||||||
#include "Gradient.h"
|
#include "Gradient.h"
|
||||||
|
|
||||||
|
|
||||||
|
#define COLOR_THEME_DEFAULT 0
|
||||||
|
#define COLOR_THEME_BW 1
|
||||||
|
#define COLOR_THEME_SHARP 2
|
||||||
|
#define COLOR_THEME_RAD 3
|
||||||
|
#define COLOR_THEME_TOUCH 4
|
||||||
|
#define COLOR_THEME_HD 5
|
||||||
|
#define COLOR_THEME_RADAR 6
|
||||||
|
#define COLOR_THEME_MAX 7
|
||||||
|
|
||||||
class WaterfallCanvas;
|
class WaterfallCanvas;
|
||||||
|
|
||||||
class WaterfallContext: public PrimaryGLContext {
|
class WaterfallContext: public PrimaryGLContext {
|
||||||
@ -11,10 +21,13 @@ public:
|
|||||||
|
|
||||||
void Draw(std::vector<float> &points);
|
void Draw(std::vector<float> &points);
|
||||||
void Setup(int fft_size_in, int num_waterfall_lines_in);
|
void Setup(int fft_size_in, int num_waterfall_lines_in);
|
||||||
|
void setTheme(int theme_id);
|
||||||
|
int getTheme();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Gradient grad;
|
Gradient *gradients[COLOR_THEME_MAX];
|
||||||
GLuint waterfall;
|
GLuint waterfall;
|
||||||
|
int theme;
|
||||||
unsigned char *waterfall_tex;
|
unsigned char *waterfall_tex;
|
||||||
int fft_size;
|
int fft_size;
|
||||||
int waterfall_lines;
|
int waterfall_lines;
|
||||||
|
Loading…
Reference in New Issue
Block a user