mirror of
https://github.com/f4exb/sdrangel.git
synced 2024-11-22 08:04:49 -05:00
Make the sideband appear correctly on SSB channel overlay
This commit is contained in:
parent
e9a93ff1c6
commit
3bb44d54bf
@ -9,6 +9,13 @@ class SDRANGELOVE_API ChannelMarker : public QObject {
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
typedef enum sidebands_e
|
||||||
|
{
|
||||||
|
dsb,
|
||||||
|
lsb,
|
||||||
|
usb
|
||||||
|
} sidebands_t;
|
||||||
|
|
||||||
ChannelMarker(QObject* parent = NULL);
|
ChannelMarker(QObject* parent = NULL);
|
||||||
|
|
||||||
void setTitle(const QString& title);
|
void setTitle(const QString& title);
|
||||||
@ -20,6 +27,9 @@ public:
|
|||||||
void setBandwidth(int bandwidth);
|
void setBandwidth(int bandwidth);
|
||||||
int getBandwidth() const { return m_bandwidth; }
|
int getBandwidth() const { return m_bandwidth; }
|
||||||
|
|
||||||
|
void setSidebands(sidebands_t sidebands);
|
||||||
|
sidebands_t getSidebands() const { return m_sidebands; }
|
||||||
|
|
||||||
void setVisible(bool visible);
|
void setVisible(bool visible);
|
||||||
bool getVisible() const { return m_visible; }
|
bool getVisible() const { return m_visible; }
|
||||||
|
|
||||||
@ -33,6 +43,7 @@ protected:
|
|||||||
QString m_title;
|
QString m_title;
|
||||||
int m_centerFrequency;
|
int m_centerFrequency;
|
||||||
int m_bandwidth;
|
int m_bandwidth;
|
||||||
|
sidebands_t m_sidebands;
|
||||||
bool m_visible;
|
bool m_visible;
|
||||||
QColor m_color;
|
QColor m_color;
|
||||||
|
|
||||||
|
@ -114,6 +114,11 @@ void SSBDemodGUI::on_BW_valueChanged(int value)
|
|||||||
QString s = QString::number(value/10.0, 'f', 1);
|
QString s = QString::number(value/10.0, 'f', 1);
|
||||||
ui->BWText->setText(s);
|
ui->BWText->setText(s);
|
||||||
m_channelMarker->setBandwidth(value * 100 * 2);
|
m_channelMarker->setBandwidth(value * 100 * 2);
|
||||||
|
if (value < 0) {
|
||||||
|
m_channelMarker->setSidebands(ChannelMarker::lsb);
|
||||||
|
} else {
|
||||||
|
m_channelMarker->setSidebands(ChannelMarker::usb);
|
||||||
|
}
|
||||||
applySettings();
|
applySettings();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -167,6 +172,7 @@ SSBDemodGUI::SSBDemodGUI(PluginAPI* pluginAPI, QWidget* parent) :
|
|||||||
m_channelMarker = new ChannelMarker(this);
|
m_channelMarker = new ChannelMarker(this);
|
||||||
m_channelMarker->setColor(Qt::green);
|
m_channelMarker->setColor(Qt::green);
|
||||||
m_channelMarker->setBandwidth(6000);
|
m_channelMarker->setBandwidth(6000);
|
||||||
|
m_channelMarker->setSidebands(ChannelMarker::usb);
|
||||||
m_channelMarker->setCenterFrequency(0);
|
m_channelMarker->setCenterFrequency(0);
|
||||||
m_channelMarker->setVisible(true);
|
m_channelMarker->setVisible(true);
|
||||||
connect(m_channelMarker, SIGNAL(changed()), this, SLOT(viewChanged()));
|
connect(m_channelMarker, SIGNAL(changed()), this, SLOT(viewChanged()));
|
||||||
|
@ -29,6 +29,7 @@ ChannelMarker::ChannelMarker(QObject* parent) :
|
|||||||
QObject(parent),
|
QObject(parent),
|
||||||
m_centerFrequency(0),
|
m_centerFrequency(0),
|
||||||
m_bandwidth(0),
|
m_bandwidth(0),
|
||||||
|
m_sidebands(dsb),
|
||||||
m_visible(false),
|
m_visible(false),
|
||||||
m_color(m_colorTable[m_nextColor])
|
m_color(m_colorTable[m_nextColor])
|
||||||
{
|
{
|
||||||
@ -55,6 +56,12 @@ void ChannelMarker::setBandwidth(int bandwidth)
|
|||||||
emit changed();
|
emit changed();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ChannelMarker::setSidebands(sidebands_t sidebands)
|
||||||
|
{
|
||||||
|
m_sidebands = sidebands;
|
||||||
|
emit changed();
|
||||||
|
}
|
||||||
|
|
||||||
void ChannelMarker::setVisible(bool visible)
|
void ChannelMarker::setVisible(bool visible)
|
||||||
{
|
{
|
||||||
m_visible = visible;
|
m_visible = visible;
|
||||||
|
@ -19,6 +19,8 @@
|
|||||||
#include <QMouseEvent>
|
#include <QMouseEvent>
|
||||||
#include "gui/glspectrum.h"
|
#include "gui/glspectrum.h"
|
||||||
|
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
GLSpectrum::GLSpectrum(QWidget* parent) :
|
GLSpectrum::GLSpectrum(QWidget* parent) :
|
||||||
QGLWidget(parent),
|
QGLWidget(parent),
|
||||||
m_cursorState(CSNormal),
|
m_cursorState(CSNormal),
|
||||||
@ -542,6 +544,17 @@ void GLSpectrum::paintGL()
|
|||||||
for(int i = 0; i < m_channelMarkerStates.size(); ++i) {
|
for(int i = 0; i < m_channelMarkerStates.size(); ++i) {
|
||||||
ChannelMarkerState* dv = m_channelMarkerStates[i];
|
ChannelMarkerState* dv = m_channelMarkerStates[i];
|
||||||
if(dv->m_channelMarker->getVisible()) {
|
if(dv->m_channelMarker->getVisible()) {
|
||||||
|
|
||||||
|
ChannelMarker::sidebands_t sidebands = dv->m_channelMarker->getSidebands();
|
||||||
|
float fcLineRelativePos;
|
||||||
|
if (sidebands == ChannelMarker::usb) {
|
||||||
|
fcLineRelativePos = 0.0;
|
||||||
|
} else if (sidebands == ChannelMarker::lsb) {
|
||||||
|
fcLineRelativePos = 1.0;
|
||||||
|
} else {
|
||||||
|
fcLineRelativePos = 0.5;
|
||||||
|
}
|
||||||
|
|
||||||
glEnable(GL_BLEND);
|
glEnable(GL_BLEND);
|
||||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||||
glColor4f(dv->m_channelMarker->getColor().redF(), dv->m_channelMarker->getColor().greenF(), dv->m_channelMarker->getColor().blueF(), 0.3f);
|
glColor4f(dv->m_channelMarker->getColor().redF(), dv->m_channelMarker->getColor().greenF(), dv->m_channelMarker->getColor().blueF(), 0.3f);
|
||||||
@ -557,8 +570,8 @@ void GLSpectrum::paintGL()
|
|||||||
glDisable(GL_BLEND);
|
glDisable(GL_BLEND);
|
||||||
glColor3f(0.8f, 0.8f, 0.6f);
|
glColor3f(0.8f, 0.8f, 0.6f);
|
||||||
glBegin(GL_LINE_LOOP);
|
glBegin(GL_LINE_LOOP);
|
||||||
glVertex2f(0.5, 0);
|
glVertex2f(fcLineRelativePos, 0);
|
||||||
glVertex2f(0.5, 1);
|
glVertex2f(fcLineRelativePos, 1);
|
||||||
glEnd();
|
glEnd();
|
||||||
glPopMatrix();
|
glPopMatrix();
|
||||||
}
|
}
|
||||||
@ -992,17 +1005,53 @@ void GLSpectrum::applyChanges()
|
|||||||
// channel overlays
|
// channel overlays
|
||||||
for(int i = 0; i < m_channelMarkerStates.size(); ++i) {
|
for(int i = 0; i < m_channelMarkerStates.size(); ++i) {
|
||||||
ChannelMarkerState* dv = m_channelMarkerStates[i];
|
ChannelMarkerState* dv = m_channelMarkerStates[i];
|
||||||
|
|
||||||
|
qreal xc, pw, nw;
|
||||||
|
ChannelMarker::sidebands_t sidebands = dv->m_channelMarker->getSidebands();
|
||||||
|
xc = m_centerFrequency + dv->m_channelMarker->getCenterFrequency(); // marker center frequency
|
||||||
|
|
||||||
|
if (sidebands == ChannelMarker::usb) {
|
||||||
|
nw = 0; // negative bandwidth
|
||||||
|
pw = dv->m_channelMarker->getBandwidth() / 2; // positive bandwidth
|
||||||
|
} else if (sidebands == ChannelMarker::lsb) {
|
||||||
|
pw = 0;
|
||||||
|
nw = dv->m_channelMarker->getBandwidth() / 2;
|
||||||
|
} else {
|
||||||
|
pw = dv->m_channelMarker->getBandwidth() / 2;
|
||||||
|
nw = -pw;
|
||||||
|
}
|
||||||
|
|
||||||
|
//std::cerr << xc << "; " << nw << "; " << pw << std::endl;
|
||||||
|
|
||||||
|
dv->m_glRect.setRect(
|
||||||
|
m_frequencyScale.getPosFromValue(xc + nw) / (float)(width() - leftMargin - rightMargin),
|
||||||
|
0,
|
||||||
|
(pw-nw) / (float)m_sampleRate,
|
||||||
|
1);
|
||||||
|
|
||||||
|
/*
|
||||||
dv->m_glRect.setRect(
|
dv->m_glRect.setRect(
|
||||||
m_frequencyScale.getPosFromValue(m_centerFrequency + dv->m_channelMarker->getCenterFrequency() - dv->m_channelMarker->getBandwidth() / 2) / (float)(width() - leftMargin - rightMargin),
|
m_frequencyScale.getPosFromValue(m_centerFrequency + dv->m_channelMarker->getCenterFrequency() - dv->m_channelMarker->getBandwidth() / 2) / (float)(width() - leftMargin - rightMargin),
|
||||||
0,
|
0,
|
||||||
(dv->m_channelMarker->getBandwidth() / (float)m_sampleRate),
|
(dv->m_channelMarker->getBandwidth() / (float)m_sampleRate),
|
||||||
1);
|
1);
|
||||||
|
*/
|
||||||
|
|
||||||
|
if(m_displayHistogram || m_displayMaxHold || m_displayWaterfall) {
|
||||||
|
dv->m_rect.setRect(m_frequencyScale.getPosFromValue(xc) + leftMargin - 1,
|
||||||
|
topMargin,
|
||||||
|
5,
|
||||||
|
height() - topMargin - bottomMargin);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
if(m_displayHistogram || m_displayMaxHold || m_displayWaterfall) {
|
if(m_displayHistogram || m_displayMaxHold || m_displayWaterfall) {
|
||||||
dv->m_rect.setRect(m_frequencyScale.getPosFromValue(m_centerFrequency + dv->m_channelMarker->getCenterFrequency()) + leftMargin - 1,
|
dv->m_rect.setRect(m_frequencyScale.getPosFromValue(m_centerFrequency + dv->m_channelMarker->getCenterFrequency()) + leftMargin - 1,
|
||||||
topMargin,
|
topMargin,
|
||||||
5,
|
5,
|
||||||
height() - topMargin - bottomMargin);
|
height() - topMargin - bottomMargin);
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
// prepare left scales (time and power)
|
// prepare left scales (time and power)
|
||||||
|
Loading…
Reference in New Issue
Block a user