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

Dynamic channel tab allocation: interim state #1

This commit is contained in:
f4exb 2015-10-07 09:27:44 +02:00
parent 162d5705dc
commit ae39dca580
3 changed files with 83 additions and 37 deletions

View File

@ -34,6 +34,7 @@ class Indicator;
class SpectrumVis; class SpectrumVis;
class GLSpectrum; class GLSpectrum;
class GLSpectrumGUI; class GLSpectrumGUI;
class ChannelWindow;
class FileSink; class FileSink;
class SampleSource; class SampleSource;
class PluginAPI; class PluginAPI;
@ -50,6 +51,17 @@ class SDRANGEL_API MainWindow : public QMainWindow {
Q_OBJECT Q_OBJECT
public: public:
struct DeviceUISet
{
SpectrumVis *m_spectrumVis;
GLSpectrum *m_spectrum;
GLSpectrumGUI *m_spectrumGUI;
ChannelWindow *m_channelWindow;
DeviceUISet(QTimer& timer);
~DeviceUISet();
};
explicit MainWindow(QWidget* parent = 0); explicit MainWindow(QWidget* parent = 0);
~MainWindow(); ~MainWindow();
@ -82,9 +94,7 @@ private:
SpectrumVis* m_rxSpectrumVis; SpectrumVis* m_rxSpectrumVis;
FileSink *m_fileSink; FileSink *m_fileSink;
std::vector<SpectrumVis*> m_spectraVis; std::vector<DeviceUISet*> m_deviceUIs;
std::vector<GLSpectrum*> m_spectra;
std::vector<GLSpectrumGUI*> m_spectraGUI;
DSPEngine* m_dspEngine; DSPEngine* m_dspEngine;

View File

@ -103,23 +103,16 @@ MainWindow::MainWindow(QWidget* parent) :
m_pluginManager->fillSampleSourceSelector(ui->sampleSource); m_pluginManager->fillSampleSourceSelector(ui->sampleSource);
ui->sampleSource->blockSignals(sampleSourceSignalsBlocked); ui->sampleSource->blockSignals(sampleSourceSignalsBlocked);
// Disable Tx spectrum by default. Enabled if source supports Tx.
ui->tabSpectra->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->
m_spectra.push_back(new GLSpectrum); m_deviceUIs.push_back(new DeviceUISet(m_masterTimer));
m_spectraVis.push_back(new SpectrumVis(m_spectra.back())); ui->tabSpectra->addTab(m_deviceUIs.back()->m_spectrum, "X0");
m_spectra.back()->connectTimer(m_masterTimer); ui->tabSpectraGUI->addTab(m_deviceUIs.back()->m_spectrumGUI, "X0");
m_spectraGUI.push_back(new GLSpectrumGUI); m_dspEngine->addSink(m_deviceUIs.back()->m_spectrumVis);
m_spectraGUI.back()->setBuddies(m_spectraVis.back()->getInputMessageQueue(), m_spectraVis.back(), m_spectra.back()); ui->tabChannels->addTab(m_deviceUIs.back()->m_channelWindow, "X0");
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);
@ -163,20 +156,9 @@ MainWindow::~MainWindow()
m_pluginManager->freeAll(); m_pluginManager->freeAll();
for (int i=0; i<m_spectraGUI.size(); i++) for (int i = 0; i < m_deviceUIs.size(); i++)
{ {
delete m_spectraGUI[i]; delete m_deviceUIs[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);
@ -197,7 +179,9 @@ void MainWindow::addChannelCreateAction(QAction* action)
void MainWindow::addChannelRollup(QWidget* widget) void MainWindow::addChannelRollup(QWidget* widget)
{ {
((ChannelWindow*)ui->channelDock->widget())->addRollupWidget(widget); m_deviceUIs.back()->m_channelWindow->addRollupWidget(widget);
//((ChannelWindow*)ui->rxChannels)->addRollupWidget(widget);
//((ChannelWindow*)ui->channelDock->widget())->addRollupWidget(widget);
ui->channelDock->show(); ui->channelDock->show();
ui->channelDock->raise(); ui->channelDock->raise();
} }
@ -210,13 +194,13 @@ 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); m_deviceUIs.back()->m_spectrum->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); m_deviceUIs.back()->m_spectrum->removeChannelMarker(channelMarker);
} }
void MainWindow::setInputGUI(QWidget* gui) void MainWindow::setInputGUI(QWidget* gui)
@ -247,7 +231,7 @@ void MainWindow::loadPresetSettings(const Preset* preset)
qPrintable(preset->getDescription())); qPrintable(preset->getDescription()));
//ui->rxSpectrumGUI->deserialize(preset->getSpectrumConfig()); //ui->rxSpectrumGUI->deserialize(preset->getSpectrumConfig());
m_spectraGUI.back()->deserialize(preset->getSpectrumConfig()); m_deviceUIs.back()->m_spectrumGUI->deserialize(preset->getSpectrumConfig());
m_pluginManager->loadSettings(preset); m_pluginManager->loadSettings(preset);
// has to be last step // has to be last step
@ -269,7 +253,7 @@ void MainWindow::savePresetSettings(Preset* preset)
qPrintable(preset->getDescription())); qPrintable(preset->getDescription()));
//preset->setSpectrumConfig(ui->rxSpectrumGUI->serialize()); //preset->setSpectrumConfig(ui->rxSpectrumGUI->serialize());
preset->setSpectrumConfig(m_spectraGUI.back()->serialize()); preset->setSpectrumConfig(m_deviceUIs.back()->m_spectrumGUI->serialize());
preset->clearChannels(); preset->clearChannels();
m_pluginManager->saveSettings(preset); m_pluginManager->saveSettings(preset);
@ -306,13 +290,13 @@ 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); m_deviceUIs.back()->m_spectrum->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_deviceUIs.back()->m_spectrum->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));
} }
@ -609,3 +593,21 @@ void MainWindow::on_action_About_triggered()
AboutDialog dlg(this); AboutDialog dlg(this);
dlg.exec(); dlg.exec();
} }
MainWindow::DeviceUISet::DeviceUISet(QTimer& timer)
{
m_spectrum = new GLSpectrum;
m_spectrumVis = new SpectrumVis(m_spectrum);
m_spectrum->connectTimer(timer);
m_spectrumGUI = new GLSpectrumGUI;
m_spectrumGUI->setBuddies(m_spectrumVis->getInputMessageQueue(), m_spectrumVis, m_spectrum);
m_channelWindow = new ChannelWindow;
}
MainWindow::DeviceUISet::~DeviceUISet()
{
delete m_channelWindow;
delete m_spectrumGUI;
delete m_spectrumVis;
delete m_spectrum;
}

View File

@ -382,6 +382,20 @@
<string>Rx</string> <string>Rx</string>
</attribute> </attribute>
<widget class="QComboBox" name="sampleSource"> <widget class="QComboBox" name="sampleSource">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>255</width>
<height>24</height>
</rect>
</property>
<property name="minimumSize">
<size>
<width>255</width>
<height>0</height>
</size>
</property>
</widget> </widget>
</widget> </widget>
</widget> </widget>
@ -396,7 +410,7 @@
<attribute name="dockWidgetArea"> <attribute name="dockWidgetArea">
<number>2</number> <number>2</number>
</attribute> </attribute>
<widget class="ChannelWindow" name="channelWindow"> <widget class="QWidget" name="channelWidgetContent">
<layout class="QVBoxLayout" name="verticalLayout_4"> <layout class="QVBoxLayout" name="verticalLayout_4">
<property name="spacing"> <property name="spacing">
<number>3</number> <number>3</number>
@ -413,6 +427,26 @@
<property name="bottomMargin"> <property name="bottomMargin">
<number>2</number> <number>2</number>
</property> </property>
<item>
<widget class="QTabWidget" name="tabChannels">
<property name="currentIndex">
<number>0</number>
</property>
<widget class="ChannelWindow" name="rxChannels">
<property name="enabled">
<bool>false</bool>
</property>
<property name="font">
<font>
<pointsize>8</pointsize>
</font>
</property>
<attribute name="title">
<string>Rx</string>
</attribute>
</widget>
</widget>
</item>
</layout> </layout>
</widget> </widget>
</widget> </widget>