1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2024-11-16 13:21:50 -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 DSPEngine;
class Indicator; class Indicator;
class SpectrumVis; class SpectrumVis;
class GLSpectrum;
class GLSpectrumGUI;
class FileSink; class FileSink;
class SampleSource; class SampleSource;
class PluginAPI; class PluginAPI;
@ -78,9 +80,12 @@ private:
MainSettings m_settings; MainSettings m_settings;
SpectrumVis* m_rxSpectrumVis; SpectrumVis* m_rxSpectrumVis;
SpectrumVis* m_txSpectrumVis;
FileSink *m_fileSink; FileSink *m_fileSink;
std::vector<SpectrumVis*> m_spectraVis;
std::vector<GLSpectrum*> m_spectra;
std::vector<GLSpectrumGUI*> m_spectraGUI;
DSPEngine* m_dspEngine; DSPEngine* m_dspEngine;
QTimer m_masterTimer; QTimer m_masterTimer;

View File

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

View File

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