mirror of
https://github.com/f4exb/sdrangel.git
synced 2025-07-22 02:35:27 -04:00
Experimental reverse video frequency dial implmented for NFM
This commit is contained in:
parent
6d27dc5e0b
commit
6ccd8732d5
@ -77,6 +77,7 @@ set(sdrbase_SOURCES
|
|||||||
sdrbase/gui/basicchannelsettingswidget.cpp
|
sdrbase/gui/basicchannelsettingswidget.cpp
|
||||||
sdrbase/gui/buttonswitch.cpp
|
sdrbase/gui/buttonswitch.cpp
|
||||||
sdrbase/gui/channelwindow.cpp
|
sdrbase/gui/channelwindow.cpp
|
||||||
|
sdrbase/gui/colormapper.cpp
|
||||||
sdrbase/gui/glscope.cpp
|
sdrbase/gui/glscope.cpp
|
||||||
sdrbase/gui/glscopegui.cpp
|
sdrbase/gui/glscopegui.cpp
|
||||||
sdrbase/gui/glspectrum.cpp
|
sdrbase/gui/glspectrum.cpp
|
||||||
@ -147,6 +148,7 @@ set(sdrbase_HEADERS
|
|||||||
include/gui/basicchannelsettingswidget.h
|
include/gui/basicchannelsettingswidget.h
|
||||||
include-gpl/gui/buttonswitch.h
|
include-gpl/gui/buttonswitch.h
|
||||||
include-gpl/gui/channelwindow.h
|
include-gpl/gui/channelwindow.h
|
||||||
|
include-gpl/gui/colormapper.h
|
||||||
include-gpl/gui/glscope.h
|
include-gpl/gui/glscope.h
|
||||||
include-gpl/gui/glscopegui.h
|
include-gpl/gui/glscopegui.h
|
||||||
include-gpl/gui/glspectrum.h
|
include-gpl/gui/glspectrum.h
|
||||||
|
41
include-gpl/gui/colormapper.h
Normal file
41
include-gpl/gui/colormapper.h
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
/*
|
||||||
|
* colormap.h
|
||||||
|
*
|
||||||
|
* Created on: Jul 19, 2015
|
||||||
|
* Author: f4exb
|
||||||
|
*/
|
||||||
|
#ifndef INCLUDE_GPL_GUI_COLORMAPPER_H_
|
||||||
|
#define INCLUDE_GPL_GUI_COLORMAPPER_H_
|
||||||
|
|
||||||
|
#include <QColor>
|
||||||
|
#include <vector>
|
||||||
|
#include <utility>
|
||||||
|
#include "util/export.h"
|
||||||
|
|
||||||
|
class SDRANGELOVE_API ColorMapper
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
enum Theme {
|
||||||
|
Normal,
|
||||||
|
ReverseGold,
|
||||||
|
};
|
||||||
|
|
||||||
|
typedef std::vector<std::pair<float, QColor> > colormap;
|
||||||
|
|
||||||
|
ColorMapper(Theme theme = Normal);
|
||||||
|
~ColorMapper();
|
||||||
|
|
||||||
|
const colormap& getDialBackgroundColorMap() const { return m_dialBackgroundcolorMap; };
|
||||||
|
const QColor& getForegroundColor() const { return m_foregroundColor; };
|
||||||
|
const QColor& getSecondaryForegroundColor() const { return m_secondaryForegroundColor; };
|
||||||
|
const QColor& getHighlightColor() const { return m_highlightColor; };
|
||||||
|
|
||||||
|
private:
|
||||||
|
Theme m_theme;
|
||||||
|
std::vector<std::pair<float, QColor> > m_dialBackgroundcolorMap;
|
||||||
|
QColor m_foregroundColor;
|
||||||
|
QColor m_secondaryForegroundColor;
|
||||||
|
QColor m_highlightColor;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif /* INCLUDE_GPL_GUI_COLORMAPPER_H_ */
|
@ -17,17 +17,20 @@
|
|||||||
|
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
|
#include "gui/colormapper.h"
|
||||||
#include "util/export.h"
|
#include "util/export.h"
|
||||||
|
|
||||||
class SDRANGELOVE_API ValueDial : public QWidget {
|
class SDRANGELOVE_API ValueDial : public QWidget {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
ValueDial(QWidget* parent = NULL);
|
ValueDial(QWidget* parent = NULL, ColorMapper colorMapper = ColorMapper(ColorMapper::Normal));
|
||||||
|
|
||||||
void setValue(quint64 value);
|
void setValue(quint64 value);
|
||||||
void setValueRange(uint numDigits, quint64 min, quint64 max);
|
void setValueRange(uint numDigits, quint64 min, quint64 max);
|
||||||
void setFont(const QFont& font);
|
void setFont(const QFont& font);
|
||||||
|
void setBold(bool bold);
|
||||||
|
void setColorMapper(ColorMapper colorMapper);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void changed(quint64 value);
|
void changed(quint64 value);
|
||||||
@ -52,6 +55,8 @@ private:
|
|||||||
QTimer m_animationTimer;
|
QTimer m_animationTimer;
|
||||||
QTimer m_blinkTimer;
|
QTimer m_blinkTimer;
|
||||||
|
|
||||||
|
ColorMapper m_colorMapper;
|
||||||
|
|
||||||
quint64 findExponent(int digit);
|
quint64 findExponent(int digit);
|
||||||
QChar digitNeigh(QChar c, bool dir);
|
QChar digitNeigh(QChar c, bool dir);
|
||||||
QString formatText(quint64 value);
|
QString formatText(quint64 value);
|
||||||
|
@ -209,6 +209,9 @@ NFMDemodGUI::NFMDemodGUI(PluginAPI* pluginAPI, QWidget* parent) :
|
|||||||
ui->ctcss->addItem(QString("%1").arg(ctcss_tones[i]));
|
ui->ctcss->addItem(QString("%1").arg(ctcss_tones[i]));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ui->deltaFrequency->setColorMapper(ColorMapper(ColorMapper::ReverseGold));
|
||||||
|
//ui->deltaFrequency->setBold(true);
|
||||||
|
|
||||||
m_channelizer = new Channelizer(m_nfmDemod);
|
m_channelizer = new Channelizer(m_nfmDemod);
|
||||||
m_threadedSampleSink = new ThreadedSampleSink(m_channelizer);
|
m_threadedSampleSink = new ThreadedSampleSink(m_channelizer);
|
||||||
m_pluginAPI->addAudioSource(m_audioFifo);
|
m_pluginAPI->addAudioSource(m_audioFifo);
|
||||||
|
53
sdrbase/gui/colormapper.cpp
Normal file
53
sdrbase/gui/colormapper.cpp
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
/*
|
||||||
|
* colormap.cpp
|
||||||
|
*
|
||||||
|
* Created on: Jul 19, 2015
|
||||||
|
* Author: f4exb
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <gui/colormapper.h>
|
||||||
|
|
||||||
|
ColorMapper::ColorMapper(Theme theme) :
|
||||||
|
m_theme(theme)
|
||||||
|
{
|
||||||
|
switch (m_theme)
|
||||||
|
{
|
||||||
|
case ReverseGold:
|
||||||
|
/*
|
||||||
|
m_dialBackgroundcolorMap.push_back(std::pair<float, QColor>(0.0, QColor(0x97, 0x54, 0x00)));
|
||||||
|
m_dialBackgroundcolorMap.push_back(std::pair<float, QColor>(0.1, QColor(0x5e, 0x34, 0x00)));
|
||||||
|
m_dialBackgroundcolorMap.push_back(std::pair<float, QColor>(0.2, QColor(0x2e, 0x19, 0x00)));
|
||||||
|
m_dialBackgroundcolorMap.push_back(std::pair<float, QColor>(0.5, QColor(0x00, 0x00, 0x00)));
|
||||||
|
m_dialBackgroundcolorMap.push_back(std::pair<float, QColor>(0.8, QColor(0x0f, 0x08, 0x00)));
|
||||||
|
m_dialBackgroundcolorMap.push_back(std::pair<float, QColor>(0.9, QColor(0x40, 0x23, 0x00)));
|
||||||
|
m_dialBackgroundcolorMap.push_back(std::pair<float, QColor>(1.0, QColor(0x97, 0x54, 0x00)));
|
||||||
|
*/
|
||||||
|
m_dialBackgroundcolorMap.push_back(std::pair<float, QColor>(0.0, QColor(0x97, 0x54, 0x00)));
|
||||||
|
m_dialBackgroundcolorMap.push_back(std::pair<float, QColor>(0.1, QColor(0x5e, 0x34, 0x00)));
|
||||||
|
m_dialBackgroundcolorMap.push_back(std::pair<float, QColor>(0.2, QColor(0x5e, 0x34, 0x00)));
|
||||||
|
m_dialBackgroundcolorMap.push_back(std::pair<float, QColor>(0.5, QColor(0x00, 0x00, 0x00)));
|
||||||
|
m_dialBackgroundcolorMap.push_back(std::pair<float, QColor>(0.8, QColor(0x5e, 0x34, 0x00)));
|
||||||
|
m_dialBackgroundcolorMap.push_back(std::pair<float, QColor>(0.9, QColor(0x40, 0x23, 0x00)));
|
||||||
|
m_dialBackgroundcolorMap.push_back(std::pair<float, QColor>(1.0, QColor(0x97, 0x54, 0x00)));
|
||||||
|
m_foregroundColor = QColor(0xff, 0x8b, 0x00);
|
||||||
|
m_secondaryForegroundColor = QColor(0xff, 0xc5, 0x80);
|
||||||
|
m_highlightColor = QColor(0xbf, 0x69, 0x00, 0x80);
|
||||||
|
break;
|
||||||
|
case Normal:
|
||||||
|
default:
|
||||||
|
m_dialBackgroundcolorMap.push_back(std::pair<float, QColor>(0.0, QColor(0x40, 0x40, 0x40)));
|
||||||
|
m_dialBackgroundcolorMap.push_back(std::pair<float, QColor>(0.1, QColor(0xc0, 0xc0, 0xc0)));
|
||||||
|
m_dialBackgroundcolorMap.push_back(std::pair<float, QColor>(0.2, QColor(0xf0, 0xf0, 0xf0)));
|
||||||
|
m_dialBackgroundcolorMap.push_back(std::pair<float, QColor>(0.5, QColor(0xff, 0xff, 0xff)));
|
||||||
|
m_dialBackgroundcolorMap.push_back(std::pair<float, QColor>(0.8, QColor(0xd0, 0xd0, 0xd0)));
|
||||||
|
m_dialBackgroundcolorMap.push_back(std::pair<float, QColor>(0.9, QColor(0xa0, 0xa0, 0xa0)));
|
||||||
|
m_dialBackgroundcolorMap.push_back(std::pair<float, QColor>(1.0, QColor(0x40, 0x40, 0x40)));
|
||||||
|
m_foregroundColor = QColor(0x00, 0x00, 0x00);
|
||||||
|
m_secondaryForegroundColor = QColor(0x10, 0x10, 0x10);
|
||||||
|
m_highlightColor = QColor(0xff, 0x00, 0x00, 0x20);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ColorMapper::~ColorMapper()
|
||||||
|
{
|
||||||
|
}
|
@ -21,9 +21,10 @@
|
|||||||
#include <QKeyEvent>
|
#include <QKeyEvent>
|
||||||
#include "gui/valuedial.h"
|
#include "gui/valuedial.h"
|
||||||
|
|
||||||
ValueDial::ValueDial(QWidget* parent) :
|
ValueDial::ValueDial(QWidget* parent, ColorMapper colorMapper) :
|
||||||
QWidget(parent),
|
QWidget(parent),
|
||||||
m_animationState(0)
|
m_animationState(0),
|
||||||
|
m_colorMapper(colorMapper)
|
||||||
{
|
{
|
||||||
setAutoFillBackground(false);
|
setAutoFillBackground(false);
|
||||||
setAttribute(Qt::WA_OpaquePaintEvent, true);
|
setAttribute(Qt::WA_OpaquePaintEvent, true);
|
||||||
@ -35,6 +36,14 @@ ValueDial::ValueDial(QWidget* parent) :
|
|||||||
m_background.setFinalStop(0, 1);
|
m_background.setFinalStop(0, 1);
|
||||||
m_background.setCoordinateMode(QGradient::ObjectBoundingMode);
|
m_background.setCoordinateMode(QGradient::ObjectBoundingMode);
|
||||||
|
|
||||||
|
ColorMapper::colormap::const_iterator cmit = m_colorMapper.getDialBackgroundColorMap().begin();
|
||||||
|
ColorMapper::colormap::const_iterator cmitEnd = m_colorMapper.getDialBackgroundColorMap().end();
|
||||||
|
|
||||||
|
for (; cmit != cmitEnd; ++ cmit) {
|
||||||
|
m_background.setColorAt(cmit->first, cmit->second);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
m_background.setColorAt(0.0, QColor(0x40, 0x40, 0x40));
|
m_background.setColorAt(0.0, QColor(0x40, 0x40, 0x40));
|
||||||
m_background.setColorAt(0.1, QColor(0xc0, 0xc0, 0xc0));
|
m_background.setColorAt(0.1, QColor(0xc0, 0xc0, 0xc0));
|
||||||
m_background.setColorAt(0.2, QColor(0xf0, 0xf0, 0xf0));
|
m_background.setColorAt(0.2, QColor(0xf0, 0xf0, 0xf0));
|
||||||
@ -42,6 +51,7 @@ ValueDial::ValueDial(QWidget* parent) :
|
|||||||
m_background.setColorAt(0.8, QColor(0xd0, 0xd0, 0xd0));
|
m_background.setColorAt(0.8, QColor(0xd0, 0xd0, 0xd0));
|
||||||
m_background.setColorAt(0.9, QColor(0xa0, 0xa0, 0xa0));
|
m_background.setColorAt(0.9, QColor(0xa0, 0xa0, 0xa0));
|
||||||
m_background.setColorAt(1.0, QColor(0x40, 0x40, 0x40));
|
m_background.setColorAt(1.0, QColor(0x40, 0x40, 0x40));
|
||||||
|
*/
|
||||||
|
|
||||||
m_value = 0;
|
m_value = 0;
|
||||||
m_valueMin = 0;
|
m_valueMin = 0;
|
||||||
@ -71,6 +81,26 @@ void ValueDial::setFont(const QFont& font)
|
|||||||
setFixedHeight(m_digitHeight * 2 + 2);
|
setFixedHeight(m_digitHeight * 2 + 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ValueDial::setBold(bool bold)
|
||||||
|
{
|
||||||
|
QFont f = font();
|
||||||
|
f.setBold(bold);
|
||||||
|
setFont(f);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ValueDial::setColorMapper(ColorMapper colorMapper)
|
||||||
|
{
|
||||||
|
m_colorMapper = colorMapper;
|
||||||
|
|
||||||
|
ColorMapper::colormap::const_iterator cmit = m_colorMapper.getDialBackgroundColorMap().begin();
|
||||||
|
ColorMapper::colormap::const_iterator cmitEnd = m_colorMapper.getDialBackgroundColorMap().end();
|
||||||
|
|
||||||
|
for (; cmit != cmitEnd; ++ cmit) {
|
||||||
|
m_background.setColorAt(cmit->first, cmit->second);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void ValueDial::setValue(quint64 value)
|
void ValueDial::setValue(quint64 value)
|
||||||
{
|
{
|
||||||
m_valueNew = value;
|
m_valueNew = value;
|
||||||
@ -158,16 +188,17 @@ void ValueDial::paintEvent(QPaintEvent*)
|
|||||||
if(m_hightlightedDigit >= 0) {
|
if(m_hightlightedDigit >= 0) {
|
||||||
painter.setPen(Qt::NoPen);
|
painter.setPen(Qt::NoPen);
|
||||||
painter.setBrush(QColor(0xff, 0x00, 0x00, 0x20));
|
painter.setBrush(QColor(0xff, 0x00, 0x00, 0x20));
|
||||||
|
painter.setBrush(m_colorMapper.getHighlightColor());
|
||||||
painter.drawRect(2 + m_hightlightedDigit * m_digitWidth, 1, m_digitWidth - 1, height() - 1);
|
painter.drawRect(2 + m_hightlightedDigit * m_digitWidth, 1, m_digitWidth - 1, height() - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(m_animationState == 0) {
|
if(m_animationState == 0) {
|
||||||
for(int i = 0; i < m_text.length(); i++) {
|
for(int i = 0; i < m_text.length(); i++) {
|
||||||
painter.setClipRect(1 + i * m_digitWidth, 1, m_digitWidth, m_digitHeight * 2);
|
painter.setClipRect(1 + i * m_digitWidth, 1, m_digitWidth, m_digitHeight * 2);
|
||||||
painter.setPen(QColor(0x10, 0x10, 0x10));
|
painter.setPen(m_colorMapper.getSecondaryForegroundColor());
|
||||||
painter.drawText(QRect(1 + i * m_digitWidth, m_digitHeight * 0.6, m_digitWidth, m_digitHeight), Qt::AlignCenter, m_text.mid(i, 1));
|
painter.drawText(QRect(1 + i * m_digitWidth, m_digitHeight * 0.6, m_digitWidth, m_digitHeight), Qt::AlignCenter, m_text.mid(i, 1));
|
||||||
if(m_text[i] != QChar('.')) {
|
if(m_text[i] != QChar('.')) {
|
||||||
painter.setPen(QColor(0x00, 0x00, 0x00));
|
painter.setPen(m_colorMapper.getForegroundColor());
|
||||||
painter.drawText(QRect(1 + i * m_digitWidth, m_digitHeight * -0.7, m_digitWidth, m_digitHeight), Qt::AlignCenter, digitNeigh(m_text[i], true));
|
painter.drawText(QRect(1 + i * m_digitWidth, m_digitHeight * -0.7, m_digitWidth, m_digitHeight), Qt::AlignCenter, digitNeigh(m_text[i], true));
|
||||||
painter.drawText(QRect(1 + i * m_digitWidth, m_digitHeight * 1.9, m_digitWidth, m_digitHeight), Qt::AlignCenter, digitNeigh(m_text[i], false));
|
painter.drawText(QRect(1 + i * m_digitWidth, m_digitHeight * 1.9, m_digitWidth, m_digitHeight), Qt::AlignCenter, digitNeigh(m_text[i], false));
|
||||||
}
|
}
|
||||||
@ -175,7 +206,7 @@ void ValueDial::paintEvent(QPaintEvent*)
|
|||||||
painter.setClipping(false);
|
painter.setClipping(false);
|
||||||
if((m_cursor >= 0) && (m_cursorState)) {
|
if((m_cursor >= 0) && (m_cursorState)) {
|
||||||
painter.setPen(Qt::NoPen);
|
painter.setPen(Qt::NoPen);
|
||||||
painter.setBrush(QColor(0x10, 0x10, 0x10));
|
painter.setBrush(m_colorMapper.getSecondaryForegroundColor());
|
||||||
painter.drawRect(4 + m_cursor * m_digitWidth, 1 + m_digitHeight * 1.5, m_digitWidth - 5, m_digitHeight / 6);
|
painter.drawRect(4 + m_cursor * m_digitWidth, 1 + m_digitHeight * 1.5, m_digitWidth - 5, m_digitHeight / 6);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -183,20 +214,20 @@ void ValueDial::paintEvent(QPaintEvent*)
|
|||||||
for(int i = 0; i < m_text.length(); i++) {
|
for(int i = 0; i < m_text.length(); i++) {
|
||||||
if(m_text[i] == m_textNew[i]) {
|
if(m_text[i] == m_textNew[i]) {
|
||||||
painter.setClipRect(1 + i * m_digitWidth, 1, m_digitWidth, m_digitHeight * 2);
|
painter.setClipRect(1 + i * m_digitWidth, 1, m_digitWidth, m_digitHeight * 2);
|
||||||
painter.setPen(QColor(0x10, 0x10, 0x10));
|
painter.setPen(m_colorMapper.getSecondaryForegroundColor());
|
||||||
painter.drawText(QRect(1 + i * m_digitWidth, m_digitHeight * 0.6, m_digitWidth, m_digitHeight), Qt::AlignCenter, m_text.mid(i, 1));
|
painter.drawText(QRect(1 + i * m_digitWidth, m_digitHeight * 0.6, m_digitWidth, m_digitHeight), Qt::AlignCenter, m_text.mid(i, 1));
|
||||||
if(m_text[i] != QChar('.')) {
|
if(m_text[i] != QChar('.')) {
|
||||||
painter.setPen(QColor(0x00, 0x00, 0x00));
|
painter.setPen(m_colorMapper.getForegroundColor());
|
||||||
painter.drawText(QRect(1 + i * m_digitWidth, m_digitHeight * -0.7, m_digitWidth, m_digitHeight), Qt::AlignCenter, digitNeigh(m_text[i], true));
|
painter.drawText(QRect(1 + i * m_digitWidth, m_digitHeight * -0.7, m_digitWidth, m_digitHeight), Qt::AlignCenter, digitNeigh(m_text[i], true));
|
||||||
painter.drawText(QRect(1 + i * m_digitWidth, m_digitHeight * 1.9, m_digitWidth, m_digitHeight), Qt::AlignCenter, digitNeigh(m_text[i], false));
|
painter.drawText(QRect(1 + i * m_digitWidth, m_digitHeight * 1.9, m_digitWidth, m_digitHeight), Qt::AlignCenter, digitNeigh(m_text[i], false));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
int h = m_digitHeight * 0.6 + m_digitHeight * m_animationState / 2.0;
|
int h = m_digitHeight * 0.6 + m_digitHeight * m_animationState / 2.0;
|
||||||
painter.setClipRect(1 + i * m_digitWidth, 1, m_digitWidth, m_digitHeight * 2);
|
painter.setClipRect(1 + i * m_digitWidth, 1, m_digitWidth, m_digitHeight * 2);
|
||||||
painter.setPen(QColor(0x10, 0x10, 0x10));
|
painter.setPen(m_colorMapper.getSecondaryForegroundColor());
|
||||||
painter.drawText(QRect(1 + i * m_digitWidth, h, m_digitWidth, m_digitHeight), Qt::AlignCenter, m_text.mid(i, 1));
|
painter.drawText(QRect(1 + i * m_digitWidth, h, m_digitWidth, m_digitHeight), Qt::AlignCenter, m_text.mid(i, 1));
|
||||||
if(m_text[i] != QChar('.')) {
|
if(m_text[i] != QChar('.')) {
|
||||||
painter.setPen(QColor(0x00, 0x00, 0x00));
|
painter.setPen(m_colorMapper.getForegroundColor());
|
||||||
painter.drawText(QRect(1 + i * m_digitWidth, h + m_digitHeight * -0.7, m_digitWidth, m_digitHeight), Qt::AlignCenter, digitNeigh(m_text[i], true));
|
painter.drawText(QRect(1 + i * m_digitWidth, h + m_digitHeight * -0.7, m_digitWidth, m_digitHeight), Qt::AlignCenter, digitNeigh(m_text[i], true));
|
||||||
painter.drawText(QRect(1 + i * m_digitWidth, h + m_digitHeight * 1.9, m_digitWidth, m_digitHeight), Qt::AlignCenter, digitNeigh(m_text[i], false));
|
painter.drawText(QRect(1 + i * m_digitWidth, h + m_digitHeight * 1.9, m_digitWidth, m_digitHeight), Qt::AlignCenter, digitNeigh(m_text[i], false));
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user