diff --git a/plugins/samplesource/airspy/airspyplugin.cpp b/plugins/samplesource/airspy/airspyplugin.cpp index 33e160558..ec85098e5 100644 --- a/plugins/samplesource/airspy/airspyplugin.cpp +++ b/plugins/samplesource/airspy/airspyplugin.cpp @@ -21,6 +21,7 @@ #include "airspygui.h" #include "airspyplugin.h" #include "plugin/pluginapi.h" +#include "device/deviceapi.h" #include "util/simpleserializer.h" const PluginDescriptor AirspyPlugin::m_pluginDescriptor = { @@ -127,7 +128,7 @@ PluginGUI* AirspyPlugin::createSampleSourcePluginGUI(const QString& sourceId, co if(sourceId == m_deviceTypeID) { AirspyGui* gui = new AirspyGui(m_pluginAPI, deviceAPI); - m_pluginAPI->setInputGUI(gui, sourceDisplayName); + deviceAPI->setInputGUI(gui, sourceDisplayName); return gui; } else diff --git a/plugins/samplesource/bladerf/bladerfplugin.cpp b/plugins/samplesource/bladerf/bladerfplugin.cpp index 891c2e946..77aa08a8d 100644 --- a/plugins/samplesource/bladerf/bladerfplugin.cpp +++ b/plugins/samplesource/bladerf/bladerfplugin.cpp @@ -18,6 +18,7 @@ #include #include #include "plugin/pluginapi.h" +#include "device/deviceapi.h" #include "util/simpleserializer.h" #include "bladerfgui.h" #include "bladerfplugin.h" @@ -85,7 +86,7 @@ PluginGUI* BlderfPlugin::createSampleSourcePluginGUI(const QString& sourceId, co if(sourceId == m_deviceTypeID) { BladerfGui* gui = new BladerfGui(m_pluginAPI, deviceAPI); - m_pluginAPI->setInputGUI(gui, sourceDisplayName); + deviceAPI->setInputGUI(gui, sourceDisplayName); return gui; } else diff --git a/plugins/samplesource/fcdpro/fcdproplugin.cpp b/plugins/samplesource/fcdpro/fcdproplugin.cpp index 0142cf37b..465aacb0b 100644 --- a/plugins/samplesource/fcdpro/fcdproplugin.cpp +++ b/plugins/samplesource/fcdpro/fcdproplugin.cpp @@ -17,6 +17,7 @@ #include #include #include "plugin/pluginapi.h" +#include "device/deviceapi.h" #include "util/simpleserializer.h" #include "fcdproplugin.h" #include "fcdprogui.h" @@ -79,7 +80,7 @@ PluginGUI* FCDProPlugin::createSampleSourcePluginGUI(const QString& sourceId, co if(sourceId == fcd_traits::interfaceIID) { FCDProGui* gui = new FCDProGui(m_pluginAPI, deviceAPI); - m_pluginAPI->setInputGUI(gui, sourceDisplayName); + deviceAPI->setInputGUI(gui, sourceDisplayName); return gui; } else diff --git a/plugins/samplesource/fcdproplus/fcdproplusplugin.cpp b/plugins/samplesource/fcdproplus/fcdproplusplugin.cpp index 5f5554eb8..218ade057 100644 --- a/plugins/samplesource/fcdproplus/fcdproplusplugin.cpp +++ b/plugins/samplesource/fcdproplus/fcdproplusplugin.cpp @@ -17,6 +17,7 @@ #include #include #include "plugin/pluginapi.h" +#include "device/deviceapi.h" #include "util/simpleserializer.h" #include "fcdproplusplugin.h" #include "fcdproplusgui.h" @@ -79,7 +80,7 @@ PluginGUI* FCDProPlusPlugin::createSampleSourcePluginGUI(const QString& sourceId if(sourceId == fcd_traits::interfaceIID) { FCDProPlusGui* gui = new FCDProPlusGui(m_pluginAPI, deviceAPI); - m_pluginAPI->setInputGUI(gui, sourceDisplayName); + deviceAPI->setInputGUI(gui, sourceDisplayName); return gui; } else diff --git a/plugins/samplesource/filesource/filesourceplugin.cpp b/plugins/samplesource/filesource/filesourceplugin.cpp index 68ffaa8c7..bc2742354 100644 --- a/plugins/samplesource/filesource/filesourceplugin.cpp +++ b/plugins/samplesource/filesource/filesourceplugin.cpp @@ -17,6 +17,7 @@ #include #include #include "plugin/pluginapi.h" +#include "device/deviceapi.h" #include "util/simpleserializer.h" #include "filesourcegui.h" @@ -72,7 +73,7 @@ PluginGUI* FileSourcePlugin::createSampleSourcePluginGUI(const QString& sourceId if(sourceId == m_deviceTypeID) { FileSourceGui* gui = new FileSourceGui(m_pluginAPI, deviceAPI); - m_pluginAPI->setInputGUI(gui, sourceDisplayName); + deviceAPI->setInputGUI(gui, sourceDisplayName); return gui; } else diff --git a/plugins/samplesource/hackrf/hackrfplugin.cpp b/plugins/samplesource/hackrf/hackrfplugin.cpp index 47c71bf6a..c50331979 100644 --- a/plugins/samplesource/hackrf/hackrfplugin.cpp +++ b/plugins/samplesource/hackrf/hackrfplugin.cpp @@ -22,6 +22,7 @@ #include "hackrfgui.h" #include "plugin/pluginapi.h" +#include "device/deviceapi.h" #include "util/simpleserializer.h" const PluginDescriptor HackRFPlugin::m_pluginDescriptor = { @@ -122,7 +123,7 @@ PluginGUI* HackRFPlugin::createSampleSourcePluginGUI(const QString& sourceId, co if(sourceId == m_deviceTypeID) { HackRFGui* gui = new HackRFGui(m_pluginAPI, deviceAPI); - m_pluginAPI->setInputGUI(gui, sourceDisplayName); + deviceAPI->setInputGUI(gui, sourceDisplayName); return gui; } else diff --git a/plugins/samplesource/rtlsdr/rtlsdrplugin.cpp b/plugins/samplesource/rtlsdr/rtlsdrplugin.cpp index ba3ace1af..d77108d54 100644 --- a/plugins/samplesource/rtlsdr/rtlsdrplugin.cpp +++ b/plugins/samplesource/rtlsdr/rtlsdrplugin.cpp @@ -2,6 +2,7 @@ #include #include #include "plugin/pluginapi.h" +#include "device/deviceapi.h" #include "util/simpleserializer.h" #include "rtlsdrplugin.h" #include "rtlsdrgui.h" @@ -63,7 +64,7 @@ PluginGUI* RTLSDRPlugin::createSampleSourcePluginGUI(const QString& sourceId, co { if(sourceId == m_deviceTypeID) { RTLSDRGui* gui = new RTLSDRGui(m_pluginAPI, deviceAPI); - m_pluginAPI->setInputGUI(gui, sourceDisplayName); + deviceAPI->setInputGUI(gui, sourceDisplayName); return gui; } else { return NULL; diff --git a/plugins/samplesource/sdrdaemon/sdrdaemonplugin.cpp b/plugins/samplesource/sdrdaemon/sdrdaemonplugin.cpp index 302fbd825..938336ab3 100644 --- a/plugins/samplesource/sdrdaemon/sdrdaemonplugin.cpp +++ b/plugins/samplesource/sdrdaemon/sdrdaemonplugin.cpp @@ -17,6 +17,7 @@ #include #include #include "plugin/pluginapi.h" +#include "device/deviceapi.h" #include "util/simpleserializer.h" #include "sdrdaemongui.h" @@ -72,7 +73,7 @@ PluginGUI* SDRdaemonPlugin::createSampleSourcePluginGUI(const QString& sourceId, if(sourceId == m_deviceTypeID) { SDRdaemonGui* gui = new SDRdaemonGui(m_pluginAPI, deviceAPI); - m_pluginAPI->setInputGUI(gui, sourceDisplayName); + deviceAPI->setInputGUI(gui, sourceDisplayName); return gui; } else diff --git a/sdrbase/device/deviceapi.cpp b/sdrbase/device/deviceapi.cpp index c08a67f64..359f752e6 100644 --- a/sdrbase/device/deviceapi.cpp +++ b/sdrbase/device/deviceapi.cpp @@ -17,8 +17,15 @@ #include "device/deviceapi.h" #include "gui/glspectrum.h" #include "gui/channelwindow.h" +#include "mainwindow.h" -DeviceAPI::DeviceAPI(DSPDeviceEngine *deviceEngine, GLSpectrum *glSpectrum, ChannelWindow *channelWindow) : +DeviceAPI::DeviceAPI(MainWindow *mainWindow, + int deviceTabIndex, + DSPDeviceEngine *deviceEngine, + GLSpectrum *glSpectrum, + ChannelWindow *channelWindow) : + m_mainWindow(mainWindow), + m_deviceTabIndex(deviceTabIndex), m_deviceEngine(deviceEngine), m_spectrum(glSpectrum), m_channelWindow(channelWindow) @@ -124,3 +131,7 @@ void DeviceAPI::addRollupWidget(QWidget *widget) m_channelWindow->addRollupWidget(widget); } +void DeviceAPI::setInputGUI(QWidget* inputGUI, const QString& sourceDisplayName) +{ + m_mainWindow->setInputGUI(m_deviceTabIndex, inputGUI, sourceDisplayName); +} diff --git a/sdrbase/device/deviceapi.h b/sdrbase/device/deviceapi.h index f744fca21..72f6fb062 100644 --- a/sdrbase/device/deviceapi.h +++ b/sdrbase/device/deviceapi.h @@ -55,18 +55,26 @@ public: MessageQueue *getDeviceInputMessageQueue(); MessageQueue *getDeviceOutputMessageQueue(); void configureCorrections(bool dcOffsetCorrection, bool iqImbalanceCorrection); //!< Configure current device engine DSP corrections + void setSourceSequence(int sourceSequence); // device related stuff GLSpectrum *getSpectrum(); //!< Direct spectrum getter void addChannelMarker(ChannelMarker* channelMarker); //!< Add channel marker to spectrum ChannelWindow *getChannelWindow(); //!< Direct channel window getter - void addRollupWidget(QWidget *widget); //!< Add rollup widget to channel window + void addRollupWidget(QWidget *widget); //!< Add rollup widget to channel window + void setInputGUI(QWidget* inputGUI, const QString& sourceDisplayName); protected: - DeviceAPI(DSPDeviceEngine *deviceEngine, GLSpectrum *glSpectrum, ChannelWindow *channelWindow); + DeviceAPI(MainWindow *mainWindow, + int deviceTabIndex, + DSPDeviceEngine *deviceEngine, + GLSpectrum *glSpectrum, + ChannelWindow *channelWindow); ~DeviceAPI(); + MainWindow *m_mainWindow; + int m_deviceTabIndex; DSPDeviceEngine *m_deviceEngine; GLSpectrum *m_spectrum; ChannelWindow *m_channelWindow; diff --git a/sdrbase/mainwindow.cpp b/sdrbase/mainwindow.cpp index 9f0219f06..cdf0cd827 100644 --- a/sdrbase/mainwindow.cpp +++ b/sdrbase/mainwindow.cpp @@ -198,7 +198,7 @@ void MainWindow::addDevice() m_deviceUIs.push_back(new DeviceUISet(m_masterTimer)); m_deviceUIs.back()->m_deviceEngine = dspDeviceEngine; - DeviceAPI *deviceAPI = new DeviceAPI(dspDeviceEngine, m_deviceUIs.back()->m_spectrum, m_deviceUIs.back()->m_channelWindow); + DeviceAPI *deviceAPI = new DeviceAPI(this, m_deviceUIs.size()-1, dspDeviceEngine, m_deviceUIs.back()->m_spectrum, m_deviceUIs.back()->m_channelWindow); m_deviceUIs.back()->m_deviceAPI = deviceAPI; // TODO: do not create one plugin manager per device. Use device API instead diff --git a/sdrbase/plugin/pluginapi.cpp b/sdrbase/plugin/pluginapi.cpp index 53ed86930..c0e13f730 100644 --- a/sdrbase/plugin/pluginapi.cpp +++ b/sdrbase/plugin/pluginapi.cpp @@ -8,11 +8,6 @@ MessageQueue* PluginAPI::getMainWindowMessageQueue() return m_mainWindow->getInputMessageQueue(); } -void PluginAPI::setInputGUI(QWidget* inputGUI, const QString& sourceDisplayName) -{ - m_pluginManager->setInputGUI(inputGUI, sourceDisplayName); -} - void PluginAPI::registerChannel(const QString& channelName, PluginInterface* plugin) { m_pluginManager->registerChannel(channelName, plugin); diff --git a/sdrbase/plugin/pluginapi.h b/sdrbase/plugin/pluginapi.h index 5a7710fd4..5724c18de 100644 --- a/sdrbase/plugin/pluginapi.h +++ b/sdrbase/plugin/pluginapi.h @@ -18,7 +18,6 @@ class SDRANGEL_API PluginAPI : public QObject { public: // MainWindow access MessageQueue* getMainWindowMessageQueue(); - void setInputGUI(QWidget* inputGUI, const QString& sourceDisplayName); // Channel stuff void registerChannel(const QString& channelName, PluginInterface* plugin); diff --git a/sdrbase/plugin/pluginmanager.cpp b/sdrbase/plugin/pluginmanager.cpp index 92580ee08..94a9acdd2 100644 --- a/sdrbase/plugin/pluginmanager.cpp +++ b/sdrbase/plugin/pluginmanager.cpp @@ -85,12 +85,6 @@ void PluginManager::registerSampleSource(const QString& sourceName, PluginInterf m_sampleSourceRegistrations.append(SampleSourceRegistration(sourceName, plugin)); } -void PluginManager::setInputGUI(QWidget* gui, const QString& sourceDisplayName) -{ - //m_mainWindow->setInputGUI(gui); - m_mainWindow->setInputGUI(m_deviceTabIndex, gui, sourceDisplayName); -} - void PluginManager::loadSettings(const Preset* preset, DeviceAPI *deviceAPI) { fprintf(stderr, "PluginManager::loadSettings: Loading preset [%s | %s]\n", qPrintable(preset->getGroup()), qPrintable(preset->getDescription())); @@ -321,7 +315,8 @@ int PluginManager::selectSampleSourceByIndex(int index, DeviceAPI *deviceAPI) << " ser: " << m_sampleSourceSerial.toStdString().c_str() << " seq: " << m_sampleSourceSequence; - m_sampleSourcePluginGUI = m_sampleSourceDevices[index].m_plugin->createSampleSourcePluginGUI(m_sampleSourceId, m_sampleSourceDevices[index].m_displayName, deviceAPI); + PluginGUI *pluginGUI = m_sampleSourceDevices[index].m_plugin->createSampleSourcePluginGUI(m_sampleSourceId, m_sampleSourceDevices[index].m_displayName, deviceAPI); + m_sampleSourcePluginGUI = pluginGUI; deviceAPI->setSourceSequence(m_sampleSourceSequence); return index; @@ -375,7 +370,9 @@ int PluginManager::selectFirstSampleSource(const QString& sourceId, DeviceAPI *d << " ser: " << m_sampleSourceSerial.toStdString().c_str() << " seq: " << m_sampleSourceSequence; - m_sampleSourcePluginGUI = m_sampleSourceDevices[index].m_plugin->createSampleSourcePluginGUI(m_sampleSourceId, m_sampleSourceDevices[index].m_displayName, deviceAPI); + PluginGUI *pluginGUI = m_sampleSourceDevices[index].m_plugin->createSampleSourcePluginGUI(m_sampleSourceId, m_sampleSourceDevices[index].m_displayName, deviceAPI); + m_sampleSourcePluginGUI = pluginGUI; + deviceAPI->setSourceSequence(m_sampleSourceSequence); return index; } @@ -442,7 +439,9 @@ int PluginManager::selectSampleSourceBySerialOrSequence(const QString& sourceId, << " ser: " << qPrintable(m_sampleSourceSerial) << " seq: " << m_sampleSourceSequence; - m_sampleSourcePluginGUI = m_sampleSourceDevices[index].m_plugin->createSampleSourcePluginGUI(m_sampleSourceId, m_sampleSourceDevices[index].m_displayName, deviceAPI); + PluginGUI *pluginGUI = m_sampleSourceDevices[index].m_plugin->createSampleSourcePluginGUI(m_sampleSourceId, m_sampleSourceDevices[index].m_displayName, deviceAPI); + m_sampleSourcePluginGUI = pluginGUI; + deviceAPI->setSourceSequence(m_sampleSourceSequence); return index; } diff --git a/sdrbase/plugin/pluginmanager.h b/sdrbase/plugin/pluginmanager.h index 223b3c3a1..dd721c53f 100644 --- a/sdrbase/plugin/pluginmanager.h +++ b/sdrbase/plugin/pluginmanager.h @@ -47,8 +47,6 @@ public: void removeChannelInstance(PluginGUI* pluginGUI); void registerSampleSource(const QString& sourceName, PluginInterface* plugin); - void setInputGUI(QWidget* gui, const QString& sourceDisplayName); - void loadSettings(const Preset* preset, DeviceAPI *deviceAPI); void loadSourceSettings(const Preset* preset); void saveSettings(Preset* preset);