1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2024-11-25 17:28:50 -05:00

Make the sideband appear correctly on SSB channel overlay

This commit is contained in:
f4exb 2015-05-11 03:27:31 +02:00
parent e9a93ff1c6
commit 3bb44d54bf
4 changed files with 75 additions and 2 deletions

View File

@ -9,6 +9,13 @@ class SDRANGELOVE_API ChannelMarker : public QObject {
Q_OBJECT
public:
typedef enum sidebands_e
{
dsb,
lsb,
usb
} sidebands_t;
ChannelMarker(QObject* parent = NULL);
void setTitle(const QString& title);
@ -20,6 +27,9 @@ public:
void setBandwidth(int bandwidth);
int getBandwidth() const { return m_bandwidth; }
void setSidebands(sidebands_t sidebands);
sidebands_t getSidebands() const { return m_sidebands; }
void setVisible(bool visible);
bool getVisible() const { return m_visible; }
@ -33,6 +43,7 @@ protected:
QString m_title;
int m_centerFrequency;
int m_bandwidth;
sidebands_t m_sidebands;
bool m_visible;
QColor m_color;

View File

@ -114,6 +114,11 @@ void SSBDemodGUI::on_BW_valueChanged(int value)
QString s = QString::number(value/10.0, 'f', 1);
ui->BWText->setText(s);
m_channelMarker->setBandwidth(value * 100 * 2);
if (value < 0) {
m_channelMarker->setSidebands(ChannelMarker::lsb);
} else {
m_channelMarker->setSidebands(ChannelMarker::usb);
}
applySettings();
}
@ -167,6 +172,7 @@ SSBDemodGUI::SSBDemodGUI(PluginAPI* pluginAPI, QWidget* parent) :
m_channelMarker = new ChannelMarker(this);
m_channelMarker->setColor(Qt::green);
m_channelMarker->setBandwidth(6000);
m_channelMarker->setSidebands(ChannelMarker::usb);
m_channelMarker->setCenterFrequency(0);
m_channelMarker->setVisible(true);
connect(m_channelMarker, SIGNAL(changed()), this, SLOT(viewChanged()));

View File

@ -29,6 +29,7 @@ ChannelMarker::ChannelMarker(QObject* parent) :
QObject(parent),
m_centerFrequency(0),
m_bandwidth(0),
m_sidebands(dsb),
m_visible(false),
m_color(m_colorTable[m_nextColor])
{
@ -55,6 +56,12 @@ void ChannelMarker::setBandwidth(int bandwidth)
emit changed();
}
void ChannelMarker::setSidebands(sidebands_t sidebands)
{
m_sidebands = sidebands;
emit changed();
}
void ChannelMarker::setVisible(bool visible)
{
m_visible = visible;

View File

@ -19,6 +19,8 @@
#include <QMouseEvent>
#include "gui/glspectrum.h"
#include <iostream>
GLSpectrum::GLSpectrum(QWidget* parent) :
QGLWidget(parent),
m_cursorState(CSNormal),
@ -542,6 +544,17 @@ void GLSpectrum::paintGL()
for(int i = 0; i < m_channelMarkerStates.size(); ++i) {
ChannelMarkerState* dv = m_channelMarkerStates[i];
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);
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);
@ -557,8 +570,8 @@ void GLSpectrum::paintGL()
glDisable(GL_BLEND);
glColor3f(0.8f, 0.8f, 0.6f);
glBegin(GL_LINE_LOOP);
glVertex2f(0.5, 0);
glVertex2f(0.5, 1);
glVertex2f(fcLineRelativePos, 0);
glVertex2f(fcLineRelativePos, 1);
glEnd();
glPopMatrix();
}
@ -992,17 +1005,53 @@ void GLSpectrum::applyChanges()
// channel overlays
for(int i = 0; i < m_channelMarkerStates.size(); ++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(
m_frequencyScale.getPosFromValue(m_centerFrequency + dv->m_channelMarker->getCenterFrequency() - dv->m_channelMarker->getBandwidth() / 2) / (float)(width() - leftMargin - rightMargin),
0,
(dv->m_channelMarker->getBandwidth() / (float)m_sampleRate),
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) {
dv->m_rect.setRect(m_frequencyScale.getPosFromValue(m_centerFrequency + dv->m_channelMarker->getCenterFrequency()) + leftMargin - 1,
topMargin,
5,
height() - topMargin - bottomMargin);
}
*/
}
// prepare left scales (time and power)