1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2024-11-26 01:39:05 -05:00

Allocate spectrum tabs dynamically

This commit is contained in:
f4exb 2015-10-07 03:53:25 +02:00
parent 21180b18fb
commit dbffb16348
3 changed files with 54 additions and 37 deletions

View File

@ -32,6 +32,8 @@ class AudioDeviceInfo;
class DSPEngine;
class Indicator;
class SpectrumVis;
class GLSpectrum;
class GLSpectrumGUI;
class FileSink;
class SampleSource;
class PluginAPI;
@ -78,9 +80,12 @@ private:
MainSettings m_settings;
SpectrumVis* m_rxSpectrumVis;
SpectrumVis* m_txSpectrumVis;
FileSink *m_fileSink;
std::vector<SpectrumVis*> m_spectraVis;
std::vector<GLSpectrum*> m_spectra;
std::vector<GLSpectrumGUI*> m_spectraGUI;
DSPEngine* m_dspEngine;
QTimer m_masterTimer;

View File

@ -36,6 +36,9 @@
#include "plugin/pluginapi.h"
#include "plugin/plugingui.h"
#include "gui/glspectrum.h"
#include "gui/glspectrumgui.h"
#include <string>
#include <QDebug>
@ -104,10 +107,19 @@ MainWindow::MainWindow(QWidget* parent) :
ui->tabSpectra->setTabEnabled(1, false);
ui->tabSpectraGUI->setTabEnabled(1, false);
m_rxSpectrumVis = new SpectrumVis(ui->rxSpectrum);
ui->rxSpectrum->connectTimer(m_masterTimer);
ui->rxSpectrumGUI->setBuddies(m_rxSpectrumVis->getInputMessageQueue(), m_rxSpectrumVis, ui->rxSpectrum);
m_dspEngine->addSink(m_rxSpectrumVis);
//m_rxSpectrumVis = new SpectrumVis(ui->rxSpectrum);
//ui->rxSpectrum->connectTimer(m_masterTimer);
//ui->rxSpectrumGUI->setBuddies(m_rxSpectrumVis->getInputMessageQueue(), m_rxSpectrumVis, ui->rxSpectrum);
//m_dspEngine->addSink(m_rxSpectrumVis);
m_spectra.push_back(new GLSpectrum);
m_spectraVis.push_back(new SpectrumVis(m_spectra.back()));
m_spectra.back()->connectTimer(m_masterTimer);
m_spectraGUI.push_back(new GLSpectrumGUI);
m_spectraGUI.back()->setBuddies(m_spectraVis.back()->getInputMessageQueue(), m_spectraVis.back(), m_spectra.back());
ui->tabSpectra->addTab(m_spectra.back(), "X0");
ui->tabSpectraGUI->addTab(m_spectraGUI.back(), "X0");
m_dspEngine->addSink(m_spectraVis.back());
m_fileSink = new FileSink();
m_dspEngine->addSink(m_fileSink);
@ -151,10 +163,26 @@ MainWindow::~MainWindow()
m_pluginManager->freeAll();
for (int i=0; i<m_spectraGUI.size(); i++)
{
delete m_spectraGUI[i];
}
for (int i=0; i<m_spectraVis.size(); i++)
{
m_dspEngine->removeSink(m_spectraVis[i]);
delete m_spectraVis[i];
}
for (int i=0; i<m_spectra.size(); i++)
{
delete m_spectra[i];
}
m_dspEngine->removeSink(m_fileSink);
m_dspEngine->removeSink(m_rxSpectrumVis);
//m_dspEngine->removeSink(m_rxSpectrumVis);
delete m_fileSink;
delete m_rxSpectrumVis;
//delete m_rxSpectrumVis;
delete m_pluginManager;
m_dspEngine->stop();
@ -181,12 +209,14 @@ void MainWindow::addViewAction(QAction* action)
void MainWindow::addChannelMarker(ChannelMarker* channelMarker)
{
ui->rxSpectrum->addChannelMarker(channelMarker);
//ui->rxSpectrum->addChannelMarker(channelMarker);
m_spectra.back()->addChannelMarker(channelMarker);
}
void MainWindow::removeChannelMarker(ChannelMarker* channelMarker)
{
ui->rxSpectrum->removeChannelMarker(channelMarker);
//ui->rxSpectrum->removeChannelMarker(channelMarker);
m_spectra.back()->removeChannelMarker(channelMarker);
}
void MainWindow::setInputGUI(QWidget* gui)
@ -216,7 +246,8 @@ void MainWindow::loadPresetSettings(const Preset* preset)
qPrintable(preset->getGroup()),
qPrintable(preset->getDescription()));
ui->rxSpectrumGUI->deserialize(preset->getSpectrumConfig());
//ui->rxSpectrumGUI->deserialize(preset->getSpectrumConfig());
m_spectraGUI.back()->deserialize(preset->getSpectrumConfig());
m_pluginManager->loadSettings(preset);
// has to be last step
@ -237,7 +268,8 @@ void MainWindow::savePresetSettings(Preset* preset)
qPrintable(preset->getGroup()),
qPrintable(preset->getDescription()));
preset->setSpectrumConfig(ui->rxSpectrumGUI->serialize());
//preset->setSpectrumConfig(ui->rxSpectrumGUI->serialize());
preset->setSpectrumConfig(m_spectraGUI.back()->serialize());
preset->clearChannels();
m_pluginManager->saveSettings(preset);
@ -273,12 +305,14 @@ void MainWindow::closeEvent(QCloseEvent*)
void MainWindow::updateCenterFreqDisplay()
{
ui->rxSpectrum->setCenterFrequency(m_centerFrequency);
//ui->rxSpectrum->setCenterFrequency(m_centerFrequency);
m_spectra.back()->setCenterFrequency(m_centerFrequency);
}
void MainWindow::updateSampleRate()
{
ui->rxSpectrum->setSampleRate(m_sampleRate);
//ui->rxSpectrum->setSampleRate(m_sampleRate);
m_spectra.back()->setSampleRate(m_sampleRate);
m_sampleRateWidget->setText(tr("Rate: %1 kHz").arg((float)m_sampleRate / 1000));
}

View File

@ -48,16 +48,11 @@
<enum>QTabWidget::Rounded</enum>
</property>
<property name="currentIndex">
<number>0</number>
<number>-1</number>
</property>
<property name="elideMode">
<enum>Qt::ElideNone</enum>
</property>
<widget class="GLSpectrum" name="rxSpectrum">
<attribute name="title">
<string>Rx</string>
</attribute>
</widget>
</widget>
</item>
</layout>
@ -329,13 +324,8 @@
</font>
</property>
<property name="currentIndex">
<number>0</number>
<number>-1</number>
</property>
<widget class="GLSpectrumGUI" name="rxSpectrumGUI">
<attribute name="title">
<string>Rx</string>
</attribute>
</widget>
</widget>
</item>
</layout>
@ -490,18 +480,6 @@
</widget>
<layoutdefault spacing="6" margin="11"/>
<customwidgets>
<customwidget>
<class>GLSpectrum</class>
<extends>QWidget</extends>
<header>gui/glspectrum.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>GLSpectrumGUI</class>
<extends>QWidget</extends>
<header>gui/glspectrumgui.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>ChannelWindow</class>
<extends>QWidget</extends>