1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2024-11-17 13:51:47 -05:00

New channel marker signal handling. Applied to channel analyzer

This commit is contained in:
f4exb 2017-11-14 00:06:42 +01:00
parent cf9c7eb8bb
commit 7b8b492bdd
7 changed files with 146 additions and 83 deletions

View File

@ -216,7 +216,7 @@ bool ChannelAnalyzer::handleMessage(const Message& cmd)
m_settingsMutex.unlock();
qDebug() << " - MsgConfigureChannelAnalyzer: m_Bandwidth: " << m_Bandwidth
qDebug() << "ChannelAnalyzer::handleMessage: MsgConfigureChannelAnalyzer: m_Bandwidth: " << m_Bandwidth
<< " m_LowCutoff: " << m_LowCutoff
<< " m_spanLog2: " << m_spanLog2
<< " m_ssb: " << m_ssb;

View File

@ -83,7 +83,7 @@ void ChannelAnalyzerGUI::resetToDefaults()
QByteArray ChannelAnalyzerGUI::serialize() const
{
SimpleSerializer s(1);
SimpleSerializer s(1);
s.writeS32(1, m_channelMarker.getCenterFrequency());
s.writeS32(2, ui->BW->value());
s.writeBlob(3, ui->spectrumGUI->serialize());
@ -92,6 +92,7 @@ QByteArray ChannelAnalyzerGUI::serialize() const
s.writeS32(6, ui->spanLog2->value());
s.writeBool(7, ui->ssb->isChecked());
s.writeBlob(8, ui->scopeGUI->serialize());
return s.final();
}
@ -139,6 +140,7 @@ bool ChannelAnalyzerGUI::deserialize(const QByteArray& data)
blockApplySettings(false);
m_channelMarker.blockSignals(false);
m_channelMarker.emitChangedByAPI();
ui->BW->setValue(bw);
ui->lowCut->setValue(lowCut); // does applySettings();
@ -178,9 +180,12 @@ void ChannelAnalyzerGUI::handleInputMessages()
}
}
void ChannelAnalyzerGUI::viewChanged()
void ChannelAnalyzerGUI::channelMarkerChangedByCursor()
{
applySettings();
ui->deltaFrequency->setValue(abs(m_channelMarker.getCenterFrequency()));
ui->deltaMinus->setChecked(m_channelMarker.getCenterFrequency() < 0);
applySettings();
}
void ChannelAnalyzerGUI::tick()
@ -346,13 +351,14 @@ ChannelAnalyzerGUI::ChannelAnalyzerGUI(PluginAPI* pluginAPI, DeviceUISet *device
ui->glScope->connectTimer(MainWindow::getInstance()->getMasterTimer());
connect(&MainWindow::getInstance()->getMasterTimer(), SIGNAL(timeout()), this, SLOT(tick()));
m_channelMarker.blockSignals(true);
m_channelMarker.setColor(Qt::gray);
m_channelMarker.setBandwidth(m_rate);
m_channelMarker.setSidebands(ChannelMarker::usb);
m_channelMarker.setCenterFrequency(0);
m_channelMarker.setVisible(true);
connect(&m_channelMarker, SIGNAL(changed()), this, SLOT(viewChanged()));
m_channelMarker.blockSignals(false);
m_channelMarker.setVisible(true); // activate signal on the last setting only
setTitleColor(m_channelMarker.getColor());
m_deviceUISet->registerRxChannelInstance(ChannelAnalyzer::m_channelID, this);
m_deviceUISet->addChannelMarker(&m_channelMarker);
@ -361,6 +367,7 @@ ChannelAnalyzerGUI::ChannelAnalyzerGUI(PluginAPI* pluginAPI, DeviceUISet *device
ui->spectrumGUI->setBuddies(m_spectrumVis->getInputMessageQueue(), m_spectrumVis, ui->glSpectrum);
ui->scopeGUI->setBuddies(m_scopeVis->getInputMessageQueue(), m_scopeVis, ui->glScope);
connect(&m_channelMarker, SIGNAL(changedByCursor()), this, SLOT(channelMarkerChangedByCursor()));
connect(getInputMessageQueue(), SIGNAL(messageEnqueued()), this, SLOT(handleInputMessages()));
applySettings();
@ -450,10 +457,6 @@ void ChannelAnalyzerGUI::applySettings()
{
if (m_doApplySettings)
{
setTitleColor(m_channelMarker.getColor());
ui->deltaFrequency->setValue(abs(m_channelMarker.getCenterFrequency()));
ui->deltaMinus->setChecked(m_channelMarker.getCenterFrequency() < 0);
ChannelAnalyzer::MsgConfigureChannelizer *msg = ChannelAnalyzer::MsgConfigureChannelizer::create(m_channelMarker.getCenterFrequency());
m_channelAnalyzer->getInputMessageQueue()->push(msg);
@ -467,15 +470,11 @@ void ChannelAnalyzerGUI::applySettings()
void ChannelAnalyzerGUI::leaveEvent(QEvent*)
{
blockApplySettings(true);
m_channelMarker.setHighlighted(false);
blockApplySettings(false);
}
void ChannelAnalyzerGUI::enterEvent(QEvent*)
{
blockApplySettings(true);
m_channelMarker.setHighlighted(true);
blockApplySettings(false);
}

View File

@ -53,17 +53,8 @@ public:
virtual MessageQueue *getInputMessageQueue() { return &m_inputMessageQueue; }
virtual bool handleMessage(const Message& message);
private slots:
void viewChanged();
void on_deltaFrequency_changed(quint64 value);
void on_deltaMinus_toggled(bool minus);
void on_BW_valueChanged(int value);
void on_lowCut_valueChanged(int value);
void on_spanLog2_valueChanged(int value);
void on_ssb_toggled(bool checked);
void onWidgetRolled(QWidget* widget, bool rollDown);
void handleInputMessages();
void tick();
public slots:
void channelMarkerChangedByCursor();
private:
Ui::ChannelAnalyzerGUI* ui;
@ -92,6 +83,17 @@ private:
void leaveEvent(QEvent*);
void enterEvent(QEvent*);
private slots:
void on_deltaFrequency_changed(quint64 value);
void on_deltaMinus_toggled(bool minus);
void on_BW_valueChanged(int value);
void on_lowCut_valueChanged(int value);
void on_spanLog2_valueChanged(int value);
void on_ssb_toggled(bool checked);
void onWidgetRolled(QWidget* widget, bool rollDown);
void handleInputMessages();
void tick();
};
#endif // INCLUDE_CHANNELANALYZERGUI_H

View File

@ -47,58 +47,75 @@ ChannelMarker::ChannelMarker(QObject* parent) :
setUDPAddress("127.0.0.1");
}
void ChannelMarker::emitChangedByAPI()
{
emit changedByAPI();
}
void ChannelMarker::setTitle(const QString& title)
{
m_title = title;
emit changed();
emit changedByAPI();
}
void ChannelMarker::setCenterFrequency(int centerFrequency)
{
m_centerFrequency = centerFrequency;
emit changed();
emit changedByAPI();
}
void ChannelMarker::setCenterFrequencyByCursor(int centerFrequency)
{
m_centerFrequency = centerFrequency;
emit changedByCursor();
}
void ChannelMarker::setBandwidth(int bandwidth)
{
m_bandwidth = bandwidth;
emit changed();
emit changedByAPI();
}
void ChannelMarker::setOppositeBandwidth(int bandwidth)
{
m_oppositeBandwidth = bandwidth;
emit changed();
emit changedByAPI();
}
void ChannelMarker::setLowCutoff(int lowCutoff)
{
m_lowCutoff = lowCutoff;
emit changed();
emit changedByAPI();
}
void ChannelMarker::setSidebands(sidebands_t sidebands)
{
m_sidebands = sidebands;
emit changed();
emit changedByAPI();
}
void ChannelMarker::setVisible(bool visible)
{
m_visible = visible;
emit changed();
emit changedByAPI();
}
void ChannelMarker::setHighlighted(bool highlighted)
{
m_highlighted = highlighted;
emit changed();
emit changedByAPI();
}
void ChannelMarker::setHighlightedByCursor(bool highlighted)
{
m_highlighted = highlighted;
emit highlightedByCursor();
}
void ChannelMarker::setColor(const QColor& color)
{
m_color = color;
emit changed();
emit changedByAPI();
}
void ChannelMarker::setUDPAddress(const QString& udpAddress)
@ -106,21 +123,21 @@ void ChannelMarker::setUDPAddress(const QString& udpAddress)
m_udpAddress = udpAddress;
m_displayAddressReceive = QString(tr("%1:%2").arg(getUDPAddress()).arg(getUDPSendPort()));
m_displayAddressReceive = QString(tr("%1:%2").arg(getUDPAddress()).arg(getUDPReceivePort()));
emit changed();
emit changedByAPI();
}
void ChannelMarker::setUDPReceivePort(quint16 port)
{
m_udpReceivePort = port;
m_displayAddressReceive = QString(tr("%1:%2").arg(getUDPAddress()).arg(getUDPReceivePort()));
emit changed();
emit changedByAPI();
}
void ChannelMarker::setUDPSendPort(quint16 port)
{
m_udpSendPort = port;
m_displayAddressSend = QString(tr("%1:%2").arg(getUDPAddress()).arg(getUDPSendPort()));
emit changed();
emit changedByAPI();
}
void ChannelMarker::resetToDefaults()

View File

@ -32,10 +32,13 @@ public:
ChannelMarker(QObject* parent = NULL);
void emitChangedByAPI();
void setTitle(const QString& title);
const QString& getTitle() const { return m_title; }
void setCenterFrequency(int centerFrequency);
void setCenterFrequencyByCursor(int centerFrequency);
int getCenterFrequency() const { return m_centerFrequency; }
void setBandwidth(int bandwidth);
@ -54,6 +57,7 @@ public:
bool getVisible() const { return m_visible; }
void setHighlighted(bool highlighted);
void setHighlightedByCursor(bool highlighted);
bool getHighlighted() const { return m_highlighted; }
void setColor(const QColor& color);
@ -104,7 +108,9 @@ protected:
void resetToDefaults();
signals:
void changed();
void changedByAPI();
void changedByCursor();
void highlightedByCursor();
};
#endif // INCLUDE_CHANNELMARKER_H

View File

@ -49,6 +49,7 @@ void BasicChannelSettingsDialog::on_colorBtn_clicked()
void BasicChannelSettingsDialog::accept()
{
m_channelMarker->blockSignals(true);
m_channelMarker->setTitle(ui->title->text());
if(m_color.isValid()) {
@ -74,9 +75,9 @@ void BasicChannelSettingsDialog::accept()
udpPort = 9999;
}
m_channelMarker->setUDPSendPort(udpPort);
m_channelMarker->setFrequencyScaleDisplayType((ChannelMarker::frequencyScaleDisplay_t) ui->fScaleDisplayType->currentIndex());
m_channelMarker->blockSignals(false);
m_channelMarker->setUDPSendPort(udpPort); // activate signal on the last setting only
m_hasChanged = true;
QDialog::accept();

View File

@ -280,7 +280,7 @@ void GLSpectrum::addChannelMarker(ChannelMarker* channelMarker)
{
QMutexLocker mutexLocker(&m_mutex);
connect(channelMarker, SIGNAL(changed()), this, SLOT(channelMarkerChanged()));
connect(channelMarker, SIGNAL(changedByAPI()), this, SLOT(channelMarkerChanged()));
connect(channelMarker, SIGNAL(destroyed(QObject*)), this, SLOT(channelMarkerDestroyed(QObject*)));
m_channelMarkerStates.append(new ChannelMarkerState(channelMarker));
m_changesPending = true;
@ -1476,7 +1476,7 @@ void GLSpectrum::applyChanges()
switch (dv->m_channelMarker->getFrequencyScaleDisplayType())
{
case ChannelMarker::FScaleDisplay_freq:
ftext = QString::number((m_centerFrequency + dv->m_channelMarker->getCenterFrequency())/1e6, 'f', 6); // TODO
ftext = QString::number((m_centerFrequency + dv->m_channelMarker->getCenterFrequency())/1e6, 'f', 6);
break;
case ChannelMarker::FScaleDisplay_title:
ftext = dv->m_channelMarker->getTitle();
@ -1597,45 +1597,73 @@ void GLSpectrum::mouseMoveEvent(QMouseEvent* event)
}
}
if(m_cursorState == CSSplitterMoving) {
float newShare;
if(!m_invertedWaterfall)
newShare = (float)(event->y() - m_frequencyScaleRect.height()) / (float)height();
else newShare = 1.0 - (float)(event->y() + m_frequencyScaleRect.height()) / (float)height();
if(newShare < 0.1)
newShare = 0.1f;
else if(newShare > 0.8)
newShare = 0.8f;
m_waterfallShare = newShare;
m_changesPending = true;
update();
return;
} else if(m_cursorState == CSChannelMoving) {
Real freq = m_frequencyScale.getValueFromPos(event->x() - m_leftMarginPixmap.width() - 1) - m_centerFrequency;
if(m_channelMarkerStates[m_cursorChannel]->m_channelMarker->getMovable())
m_channelMarkerStates[m_cursorChannel]->m_channelMarker->setCenterFrequency(freq);
}
if (m_cursorState == CSSplitterMoving)
{
float newShare;
if(m_displayWaterfall || m_displayHistogram || m_displayMaxHold || m_displayCurrent) {
for(int i = 0; i < m_channelMarkerStates.size(); ++i) {
if(m_channelMarkerStates[i]->m_rect.contains(event->pos())) {
if(m_cursorState == CSNormal) {
setCursor(Qt::SizeHorCursor);
m_cursorState = CSChannel;
m_cursorChannel = i;
m_channelMarkerStates[i]->m_channelMarker->setHighlighted(true);
return;
} else if(m_cursorState == CSChannel) {
return;
}
} else if (m_channelMarkerStates[i]->m_channelMarker->getHighlighted()) {
m_channelMarkerStates[i]->m_channelMarker->setHighlighted(false);
}
}
}
if(m_cursorState == CSChannel) {
if (!m_invertedWaterfall) {
newShare = (float) (event->y() - m_frequencyScaleRect.height()) / (float) height();
} else {
newShare = 1.0 - (float) (event->y() + m_frequencyScaleRect.height()) / (float) height();
}
if (newShare < 0.1) {
newShare = 0.1f;
} else if (newShare > 0.8) {
newShare = 0.8f;
}
m_waterfallShare = newShare;
m_changesPending = true;
update();
return;
}
else if (m_cursorState == CSChannelMoving)
{
Real freq = m_frequencyScale.getValueFromPos(event->x() - m_leftMarginPixmap.width() - 1) - m_centerFrequency;
if (m_channelMarkerStates[m_cursorChannel]->m_channelMarker->getMovable())
{
m_channelMarkerStates[m_cursorChannel]->m_channelMarker->setCenterFrequencyByCursor(freq);
channelMarkerChanged();
}
}
if (m_displayWaterfall || m_displayHistogram || m_displayMaxHold || m_displayCurrent)
{
for (int i = 0; i < m_channelMarkerStates.size(); ++i)
{
if (m_channelMarkerStates[i]->m_rect.contains(event->pos()))
{
if (m_cursorState == CSNormal)
{
setCursor(Qt::SizeHorCursor);
m_cursorState = CSChannel;
m_cursorChannel = i;
m_channelMarkerStates[i]->m_channelMarker->setHighlightedByCursor(true);
channelMarkerChanged();
return;
}
else if (m_cursorState == CSChannel)
{
return;
}
}
else if (m_channelMarkerStates[i]->m_channelMarker->getHighlighted())
{
m_channelMarkerStates[i]->m_channelMarker->setHighlightedByCursor(false);
channelMarkerChanged();
}
}
}
if(m_cursorState == CSChannel)
{
setCursor(Qt::ArrowCursor);
m_cursorState = CSNormal;
return;
}
}
@ -1645,22 +1673,32 @@ void GLSpectrum::mousePressEvent(QMouseEvent* event)
if(event->button() != 1)
return;
if(m_cursorState == CSSplitter) {
if(m_cursorState == CSSplitter)
{
grabMouse();
m_cursorState = CSSplitterMoving;
return;
} else if(m_cursorState == CSChannel) {
}
else if(m_cursorState == CSChannel)
{
grabMouse();
m_cursorState = CSChannelMoving;
return;
} else if((m_cursorState == CSNormal) && (m_channelMarkerStates.size() == 1)) {
}
else if((m_cursorState == CSNormal) && (m_channelMarkerStates.size() == 1))
{
grabMouse();
setCursor(Qt::SizeHorCursor);
m_cursorState = CSChannelMoving;
m_cursorChannel = 0;
Real freq = m_frequencyScale.getValueFromPos(event->x() - m_leftMarginPixmap.width() - 1) - m_centerFrequency;
if(m_channelMarkerStates[m_cursorChannel]->m_channelMarker->getMovable())
m_channelMarkerStates[m_cursorChannel]->m_channelMarker->setCenterFrequency(freq);
{
m_channelMarkerStates[m_cursorChannel]->m_channelMarker->setCenterFrequencyByCursor(freq);
channelMarkerChanged();
}
return;
}
}