diff --git a/Software/PC_Application/Calibration/amplitudecaldialog.cpp b/Software/PC_Application/Calibration/amplitudecaldialog.cpp index 3c4c3dc..9425aa3 100644 --- a/Software/PC_Application/Calibration/amplitudecaldialog.cpp +++ b/Software/PC_Application/Calibration/amplitudecaldialog.cpp @@ -17,15 +17,16 @@ using namespace std; using namespace nlohmann; -AmplitudeCalDialog::AmplitudeCalDialog(Device *dev, QWidget *parent) : +AmplitudeCalDialog::AmplitudeCalDialog(Device *dev, ModeHandler *handler, QWidget *parent) : QDialog(parent), ui(new Ui::AmplitudeCalDialog), dev(dev), + modeHandler(handler), model(this), mode(CalibrationMode::BothPorts) { - activeMode = Mode::getActiveMode(); - activeMode->deactivate(); + auto activeMode = modeHandler->getActiveMode(); + modeHandler->deactivate(activeMode); dev->SetIdle(); ui->setupUi(this); ui->view->setModel(&model); @@ -137,7 +138,8 @@ AmplitudeCalDialog::AmplitudeCalDialog(Device *dev, QWidget *parent) : AmplitudeCalDialog::~AmplitudeCalDialog() { delete ui; - activeMode->activate(); + auto activeMode = modeHandler->getActiveMode(); + modeHandler->activate(activeMode); } void AmplitudeCalDialog::reject() diff --git a/Software/PC_Application/Calibration/amplitudecaldialog.h b/Software/PC_Application/Calibration/amplitudecaldialog.h index 0abcbd8..d36516d 100644 --- a/Software/PC_Application/Calibration/amplitudecaldialog.h +++ b/Software/PC_Application/Calibration/amplitudecaldialog.h @@ -2,6 +2,7 @@ #define AMPLITUDECALDIALOG_H #include "mode.h" +#include "modehandler.h" #include "Device/device.h" #include @@ -42,7 +43,7 @@ class AmplitudeCalDialog : public QDialog Q_OBJECT public: - explicit AmplitudeCalDialog(Device *dev, QWidget *parent = nullptr); + explicit AmplitudeCalDialog(Device *dev, ModeHandler *handler, QWidget *parent = nullptr); ~AmplitudeCalDialog(); void reject() override; @@ -100,7 +101,7 @@ protected: std::vector points; Ui::AmplitudeCalDialog *ui; Device *dev; - Mode *activeMode; + ModeHandler *modeHandler; AmplitudeModel model; bool edited; CalibrationMode mode; diff --git a/Software/PC_Application/Calibration/frequencycaldialog.cpp b/Software/PC_Application/Calibration/frequencycaldialog.cpp index df2d403..abd04f8 100644 --- a/Software/PC_Application/Calibration/frequencycaldialog.cpp +++ b/Software/PC_Application/Calibration/frequencycaldialog.cpp @@ -2,7 +2,7 @@ #include "ui_frequencycaldialog.h" -FrequencyCalDialog::FrequencyCalDialog(Device *dev, QWidget *parent) : +FrequencyCalDialog::FrequencyCalDialog(Device *dev, ModeHandler *handler, QWidget *parent) : QDialog(parent), ui(new Ui::FrequencyCalDialog), dev(dev) @@ -22,9 +22,9 @@ FrequencyCalDialog::FrequencyCalDialog(Device *dev, QWidget *parent) : p.frequencyCorrection.ppm = ui->ppm->value(); dev->SendPacket(p); // force restart of current mode for setting to take effect - auto activeMode = Mode::getActiveMode(); - activeMode->deactivate(); - activeMode->activate(); + auto activeMode = handler->getActiveMode(); + handler->deactivate(activeMode); + handler->activate(activeMode); accept(); delete this; }); diff --git a/Software/PC_Application/Calibration/frequencycaldialog.h b/Software/PC_Application/Calibration/frequencycaldialog.h index 7358407..9ddf4e9 100644 --- a/Software/PC_Application/Calibration/frequencycaldialog.h +++ b/Software/PC_Application/Calibration/frequencycaldialog.h @@ -2,6 +2,7 @@ #define FREQUENCYCALDIALOG_H #include "Device/device.h" +#include "modehandler.h" #include "mode.h" #include @@ -15,7 +16,7 @@ class FrequencyCalDialog : public QDialog Q_OBJECT public: - explicit FrequencyCalDialog(Device *dev, QWidget *parent = nullptr); + explicit FrequencyCalDialog(Device *dev, ModeHandler *handler, QWidget *parent = nullptr); ~FrequencyCalDialog(); private: diff --git a/Software/PC_Application/Calibration/receivercaldialog.cpp b/Software/PC_Application/Calibration/receivercaldialog.cpp index 1b74176..bd64cfe 100644 --- a/Software/PC_Application/Calibration/receivercaldialog.cpp +++ b/Software/PC_Application/Calibration/receivercaldialog.cpp @@ -1,7 +1,7 @@ #include "receivercaldialog.h" -ReceiverCalDialog::ReceiverCalDialog(Device *dev) - : AmplitudeCalDialog(dev) +ReceiverCalDialog::ReceiverCalDialog(Device *dev, ModeHandler *handler) + : AmplitudeCalDialog(dev, handler) { setWindowTitle("Receiver Calibration Dialog"); LoadFromDevice(); diff --git a/Software/PC_Application/Calibration/receivercaldialog.h b/Software/PC_Application/Calibration/receivercaldialog.h index 1032c73..28fecf4 100644 --- a/Software/PC_Application/Calibration/receivercaldialog.h +++ b/Software/PC_Application/Calibration/receivercaldialog.h @@ -2,12 +2,13 @@ #define RECEIVERCALDIALOG_H #include "amplitudecaldialog.h" +#include "modehandler.h" class ReceiverCalDialog : public AmplitudeCalDialog { Q_OBJECT public: - ReceiverCalDialog(Device *dev); + ReceiverCalDialog(Device *dev, ModeHandler *handler); protected: Protocol::PacketType requestCommand() override { return Protocol::PacketType::RequestReceiverCal; } Protocol::PacketType pointType() override { return Protocol::PacketType::ReceiverCalPoint; } diff --git a/Software/PC_Application/Calibration/sourcecaldialog.cpp b/Software/PC_Application/Calibration/sourcecaldialog.cpp index 9d047b1..c511920 100644 --- a/Software/PC_Application/Calibration/sourcecaldialog.cpp +++ b/Software/PC_Application/Calibration/sourcecaldialog.cpp @@ -2,8 +2,8 @@ #include -SourceCalDialog::SourceCalDialog(Device *dev) - : AmplitudeCalDialog(dev) +SourceCalDialog::SourceCalDialog(Device *dev, ModeHandler *handler) + : AmplitudeCalDialog(dev, handler) { setWindowTitle("Source Calibration Dialog"); LoadFromDevice(); diff --git a/Software/PC_Application/Calibration/sourcecaldialog.h b/Software/PC_Application/Calibration/sourcecaldialog.h index 7bd691c..f343e3b 100644 --- a/Software/PC_Application/Calibration/sourcecaldialog.h +++ b/Software/PC_Application/Calibration/sourcecaldialog.h @@ -2,6 +2,7 @@ #define SOURCECALDIALOG_H #include "amplitudecaldialog.h" +#include "modehandler.h" #include @@ -9,7 +10,7 @@ class SourceCalDialog : public AmplitudeCalDialog { Q_OBJECT public: - SourceCalDialog(Device *dev); + SourceCalDialog(Device *dev, ModeHandler *handler); protected: Protocol::PacketType requestCommand() override { return Protocol::PacketType::RequestSourceCal; } Protocol::PacketType pointType() override { return Protocol::PacketType::SourceCalPoint; } diff --git a/Software/PC_Application/Generator/generator.cpp b/Software/PC_Application/Generator/generator.cpp index 94d4d0f..efecde8 100644 --- a/Software/PC_Application/Generator/generator.cpp +++ b/Software/PC_Application/Generator/generator.cpp @@ -1,4 +1,5 @@ #include "generator.h" +#include "modehandler.h" #include @@ -55,7 +56,7 @@ void Generator::fromJSON(nlohmann::json j) void Generator::updateDevice() { - if(!window->getDevice() || Mode::getActiveMode() != this) { + if(!window->getDevice() || window->getModeHandler()->getActiveMode() != this) { // can't update if not connected return; } diff --git a/Software/PC_Application/SpectrumAnalyzer/spectrumanalyzer.cpp b/Software/PC_Application/SpectrumAnalyzer/spectrumanalyzer.cpp index de035c7..cc2cf6d 100644 --- a/Software/PC_Application/SpectrumAnalyzer/spectrumanalyzer.cpp +++ b/Software/PC_Application/SpectrumAnalyzer/spectrumanalyzer.cpp @@ -17,6 +17,7 @@ #include "Device/firmwareupdatedialog.h" #include "preferences.h" #include "Generator/signalgenwidget.h" +#include "modehandler.h" #include #include @@ -433,7 +434,7 @@ using namespace std; void SpectrumAnalyzer::NewDatapoint(Protocol::SpectrumAnalyzerResult d) { - if(Mode::getActiveMode() != this) { + if(window->getModeHandler()->getActiveMode() != this) { return; } @@ -570,7 +571,7 @@ void SpectrumAnalyzer::SettingsChanged() } } - if(window->getDevice() && Mode::getActiveMode() == this) { + if(window->getDevice() && window->getModeHandler()->getActiveMode() == this) { window->getDevice()->Configure(settings, [=](Device::TransmissionResult res){ // device received command changingSettings = false; diff --git a/Software/PC_Application/VNA/vna.cpp b/Software/PC_Application/VNA/vna.cpp index fc0cd22..b176d78 100644 --- a/Software/PC_Application/VNA/vna.cpp +++ b/Software/PC_Application/VNA/vna.cpp @@ -22,6 +22,7 @@ #include "Calibration/manualcalibrationdialog.h" #include "Util/util.h" #include "Tools/parameters.h" +#include "modehandler.h" #include #include @@ -801,7 +802,7 @@ using namespace std; void VNA::NewDatapoint(Protocol::Datapoint d) { - if(Mode::getActiveMode() != this) { + if(window->getModeHandler()->getActiveMode() != this) { // ignore return; } @@ -972,7 +973,7 @@ void VNA::SettingsChanged(bool resetTraces, std::functiongetDevice() && Mode::getActiveMode() == this) { + if(window->getDevice() && window->getModeHandler()->getActiveMode() == this) { if(s.excitePort1 == 0 && s.excitePort2 == 0) { // no signal at either port, just set the device to idle window->getDevice()->SetIdle(); @@ -1486,7 +1487,7 @@ void VNA::SetupSCPI() return ret; })); scpi_cal->add(new SCPICommand("MEASure", [=](QStringList params) -> QString { - if(params.size() != 1 || CalibrationMeasurementActive() || !window->getDevice() || Mode::getActiveMode() != this) { + if(params.size() != 1 || CalibrationMeasurementActive() || !window->getDevice() || window->getModeHandler()->getActiveMode() != this) { // no measurement specified, still busy or invalid mode return SCPI::getResultName(SCPI::Result::Error); } else { diff --git a/Software/PC_Application/appwindow.cpp b/Software/PC_Application/appwindow.cpp index 12c788b..11c87b1 100644 --- a/Software/PC_Application/appwindow.cpp +++ b/Software/PC_Application/appwindow.cpp @@ -264,7 +264,7 @@ AppWindow::AppWindow(QWidget *parent) LoadSetup(filename); }); connect(ui->actionSave_image, &QAction::triggered, [=](){ - Mode::getActiveMode()->saveSreenshot(); + modeHandler->getActiveMode()->saveSreenshot(); }); connect(ui->actionManual_Control, &QAction::triggered, this, &AppWindow::StartManualControl); @@ -284,17 +284,38 @@ AppWindow::AppWindow(QWidget *parent) StartTCPServer(p.SCPIServer.port); } } - - if(p.Acquisition.useMedianAveraging) { - modeHandler->setAveragingMode(Averaging::Mode::Median); - } else { - modeHandler->setAveragingMode(Averaging::Mode::Mean); + // averaging mode may have changed, update for all relevant modes + for (auto m : modeHandler->getModes()) + { + switch (m->getType()) + { + case Mode::Type::VNA: + if(p.Acquisition.useMedianAveraging) { + static_cast(m)->setAveragingMode(Averaging::Mode::Median); + } + else { + static_cast(m)->setAveragingMode(Averaging::Mode::Mean); + } + break; + case Mode::Type::SA: + if(p.Acquisition.useMedianAveraging) { + static_cast(m)->setAveragingMode(Averaging::Mode::Median); + } + else { + static_cast(m)->setAveragingMode(Averaging::Mode::Mean); + } + break; + case Mode::Type::SG: + case Mode::Type::Last: + default: + break; + } } // acquisition frequencies may have changed, update UpdateAcquisitionFrequencies(); - auto active = Mode::getActiveMode(); + auto active = modeHandler->getActiveMode(); if (active) { active->updateGraphColors(); @@ -369,8 +390,8 @@ void AppWindow::closeEvent(QCloseEvent *event) QSettings settings; settings.setValue("geometry", saveGeometry()); // deactivate currently used mode (stores mode state in settings) - if(Mode::getActiveMode()) { - Mode::getActiveMode()->deactivate(); + if(modeHandler->getActiveMode()) { + modeHandler->deactivate(modeHandler->getActiveMode()); } delete device; delete modeHandler; @@ -406,8 +427,8 @@ bool AppWindow::ConnectToDevice(QString serial) ui->actionFrequency_Calibration->setEnabled(true); UpdateAcquisitionFrequencies(); - if (Mode::getActiveMode()) { - Mode::getActiveMode()->initializeDevice(); + if (modeHandler->getActiveMode()) { + modeHandler->getActiveMode()->initializeDevice(); } UpdateReference(); @@ -445,8 +466,8 @@ void AppWindow::DisconnectDevice() deviceActionGroup->checkedAction()->setChecked(false); } UpdateStatusBar(DeviceStatusBar::Disconnected); - if(Mode::getActiveMode()) { - Mode::getActiveMode()->deviceDisconnected(); + if(modeHandler->getActiveMode()) { + modeHandler->getActiveMode()->deviceDisconnected(); } qDebug() << "Disconnected device"; } @@ -585,7 +606,6 @@ void AppWindow::SetupSCPI() return "INVALID MDOE"; } if(mode) { - mode->activate(); int index = modeHandler->findIndex(mode); modeHandler->setCurrentIndex(index); return SCPI::getResultName(SCPI::Result::Empty); @@ -593,7 +613,7 @@ void AppWindow::SetupSCPI() return SCPI::getResultName(SCPI::Result::Error); } }, [=](QStringList) -> QString { - auto active = Mode::getActiveMode(); + auto active = modeHandler->getActiveMode(); if(active) { switch(active->getType()) { case Mode::Type::VNA: return "VNA"; @@ -955,7 +975,7 @@ void AppWindow::StartManualControl() connect(manual, &QDialog::finished, [=](){ manual = nullptr; if(device) { - Mode::getActiveMode()->initializeDevice(); + modeHandler->getActiveMode()->initializeDevice(); } }); if(AppWindow::showGUI()) { @@ -1035,7 +1055,7 @@ void AppWindow::DeviceStatusUpdated() void AppWindow::SourceCalibrationDialog() { - auto d = new SourceCalDialog(device); + auto d = new SourceCalDialog(device, modeHandler); if(AppWindow::showGUI()) { d->exec(); } @@ -1043,7 +1063,7 @@ void AppWindow::SourceCalibrationDialog() void AppWindow::ReceiverCalibrationDialog() { - auto d = new ReceiverCalDialog(device); + auto d = new ReceiverCalDialog(device, modeHandler); if(AppWindow::showGUI()) { d->exec(); } @@ -1051,7 +1071,7 @@ void AppWindow::ReceiverCalibrationDialog() void AppWindow::FrequencyCalibrationDialog() { - auto d = new FrequencyCalDialog(device); + auto d = new FrequencyCalDialog(device, modeHandler); if(AppWindow::showGUI()) { d->exec(); } @@ -1082,8 +1102,8 @@ nlohmann::json AppWindow::SaveSetup() jm.push_back(jmode); } j["Modes"] = jm; - if(Mode::getActiveMode()) { - j["activeMode"] = Mode::getActiveMode()->getName().toStdString(); + if(modeHandler->getActiveMode()) { + j["activeMode"] = modeHandler->getActiveMode()->getName().toStdString(); } nlohmann::json ref; @@ -1171,8 +1191,8 @@ void AppWindow::LoadSetup(nlohmann::json j) } } // if no mode is activated, there might have been a problem with the setup file. Activate the first mode anyway, to prevent invalid GUI state - if(!Mode::getActiveMode() && modeHandler->getModes().size() > 0) { - modeHandler->getModes()[0]->activate(); + if(!modeHandler->getActiveMode() && modeHandler->getModes().size() > 0) { + modeHandler->activate(modeHandler->getModes()[0]); } } @@ -1186,6 +1206,12 @@ QStackedWidget *AppWindow::getCentral() const return central; } +ModeHandler* AppWindow::getModeHandler() const +{ + return modeHandler; +} + + Ui::MainWindow *AppWindow::getUi() const { return ui; diff --git a/Software/PC_Application/appwindow.h b/Software/PC_Application/appwindow.h index 8b1269e..3fcc8b9 100644 --- a/Software/PC_Application/appwindow.h +++ b/Software/PC_Application/appwindow.h @@ -42,6 +42,7 @@ public: Ui::MainWindow *getUi() const; QStackedWidget *getCentral() const; + ModeHandler* getModeHandler() const; Device*&getDevice(); const QString& getAppVersion() const; diff --git a/Software/PC_Application/mode.cpp b/Software/PC_Application/mode.cpp index 998b0db..b5eb493 100644 --- a/Software/PC_Application/mode.cpp +++ b/Software/PC_Application/mode.cpp @@ -13,7 +13,6 @@ #include #include -Mode* Mode::activeMode = nullptr; //QButtonGroup* Mode::modeButtonGroup = nullptr; Mode::Mode(AppWindow *window, QString name, QString SCPIname) @@ -29,9 +28,6 @@ Mode::Mode(AppWindow *window, QString name, QString SCPIname) Mode::~Mode() { window->getSCPI()->remove(this); - if(activeMode == this) { - deactivate(); - } window->getCentral()->removeWidget(central); delete central; for(auto d : docks) { @@ -44,13 +40,6 @@ Mode::~Mode() void Mode::activate() { - if(activeMode == this) { - // already active; - return; - } else if(activeMode) { - activeMode->deactivate(); - } - qDebug() << "Activating mode" << name; // show all mode specific GUI elements for(auto t : toolbars) { @@ -88,8 +77,6 @@ void Mode::activate() } } - activeMode = this; - if(window->getDevice()) { initializeDevice(); } @@ -126,12 +113,6 @@ void Mode::deactivate() if(window->getDevice()) { window->getDevice()->SetIdle(); } - activeMode = nullptr; -} - -Mode *Mode::getActiveMode() -{ - return activeMode; } QString Mode::TypeToName(Mode::Type t) @@ -168,16 +149,6 @@ void Mode::saveSreenshot() central->grab().save(filename); } -Mode *Mode::createNew(AppWindow *window, QString name, Mode::Type t) -{ - switch(t) { - case Type::VNA: return new VNA(window, name); - case Type::SG: return new Generator(window, name); - case Type::SA: return new SpectrumAnalyzer(window, name); - default: return nullptr; - } -} - void Mode::finalize(QWidget *centralWidget) { central = centralWidget; @@ -204,9 +175,7 @@ void Mode::finalize(QWidget *centralWidget) void Mode::setStatusbarMessage(QString msg) { statusbarMsg = msg; - if(this == activeMode) { - emit statusbarMessage(msg); - } + emit statusbarMessage(msg); } QString Mode::getName() const diff --git a/Software/PC_Application/mode.h b/Software/PC_Application/mode.h index ce1627c..e554776 100644 --- a/Software/PC_Application/mode.h +++ b/Software/PC_Application/mode.h @@ -16,6 +16,7 @@ class Mode : public QObject, public Savable, public SCPINode { Q_OBJECT + friend class ModeHandler; public: enum class Type { VNA, @@ -27,13 +28,10 @@ public: Mode(AppWindow *window, QString name, QString SCPIname); ~Mode(); - virtual void activate(); // derived classes must call Mode::activate before doing anything - virtual void deactivate(); // derived classes must call Mode::deactivate before returning virtual void shutdown(){}; // called when the application is about to exit QString getName() const; void setName(const QString &value); void updateGraphColors(); - static Mode *getActiveMode(); static QString TypeToName(Type t); static Type TypeFromName(QString s); virtual Type getType() = 0; @@ -43,11 +41,13 @@ public: virtual void saveSreenshot(); - static Mode *createNew(AppWindow *window, QString name, Type t); - signals: void statusbarMessage(QString msg); protected: + + virtual void activate(); // derived classes must call Mode::activate before doing anything + virtual void deactivate(); // derived classes must call Mode::deactivate before returning + void setStatusbarMessage(QString msg); // call once the derived class is fully initialized void finalize(QWidget *centralWidget); @@ -57,8 +57,6 @@ protected: std::set docks; private: - static std::vector modes; - static Mode *activeMode; // static QButtonGroup *modeButtonGroup; QString name; QString statusbarMsg; diff --git a/Software/PC_Application/modehandler.cpp b/Software/PC_Application/modehandler.cpp index d456e5c..b42a79e 100644 --- a/Software/PC_Application/modehandler.cpp +++ b/Software/PC_Application/modehandler.cpp @@ -20,7 +20,7 @@ void ModeHandler::shutdown() int ModeHandler::createMode(QString name, Mode::Type t) { - auto mode = Mode::createNew(aw, name, t); + auto mode = createNew(aw, name, t); return createMode(mode); } @@ -30,18 +30,52 @@ int ModeHandler::createMode(Mode *mode) currentModeIndex = int(modes.size()) - 1; connect(mode, &Mode::statusbarMessage, this, &ModeHandler::setStatusBarMessageChanged); - auto * m = getMode(currentModeIndex); - m->activate(); + auto m = getMode(currentModeIndex); + activate(m); emit ModeCreated(currentModeIndex); return (currentModeIndex); } +Mode *ModeHandler::createNew(AppWindow *aw, QString name, Mode::Type t) +{ + switch(t) { + case Mode::Type::VNA: return new VNA(aw, name); + case Mode::Type::SG: return new Generator(aw, name); + case Mode::Type::SA: return new SpectrumAnalyzer(aw, name); + default: return nullptr; + } +} + +Mode* ModeHandler::getActiveMode() +{ + return activeMode; +} + Mode* ModeHandler::getMode(int index) { return modes.at(index); } +void ModeHandler::activate(Mode * mode) +{ + if (getActiveMode() == mode) { + // Already active + return; + } + else if (getActiveMode()) { + deactivate(getActiveMode()); + } + activeMode = mode; + mode->activate(); +} + +void ModeHandler::deactivate(Mode* mode) +{ + mode->deactivate(); + activeMode = nullptr; +} + std::vector ModeHandler::getModes() { return modes; @@ -51,8 +85,8 @@ void ModeHandler::setCurrentIndex(int index) { if (index >= 0) { currentModeIndex = index; - auto * m = getMode(getCurrentIndex()); - m->activate(); + auto m = getMode(getCurrentIndex()); + activate(m); emit CurrentModeChanged(getCurrentIndex()); } } @@ -111,6 +145,10 @@ void ModeHandler::closeMode(int index) } } + if (getActiveMode() == modes.at(index)) { + deactivate(getActiveMode()); + } + delete modes.at(index); modes.erase(modes.begin() + index); @@ -130,7 +168,10 @@ void ModeHandler::closeModes() void ModeHandler::setStatusBarMessageChanged(const QString &msg) { - emit StatusBarMessageChanged(msg); + QObject* mode = sender(); + if ( getActiveMode() == mode) { + emit StatusBarMessageChanged(msg); + } } bool ModeHandler::nameAllowed(const QString &name) @@ -161,36 +202,3 @@ Mode* ModeHandler::findFirstOfType(Mode::Type t) } return nullptr; } - -void ModeHandler::setAveragingMode(Averaging::Mode value) -{ - - - // averaging mode may have changed, update for all relevant modes - for (auto m : getModes()) - { - switch (m->getType()) - { - case Mode::Type::VNA: - static_cast(m)->setAveragingMode(value); - break; - case Mode::Type::SA: - static_cast(m)->setAveragingMode(value); - break; - case Mode::Type::SG: - case Mode::Type::Last: - default: - break; - } - } - - for(auto m : modes) { - if (m->getType() == Mode::Type::SA) { - static_cast(m)->setAveragingMode(value); - } - else if (m->getType() == Mode::Type::VNA) { - static_cast(m)->setAveragingMode(value); - } - } -} - diff --git a/Software/PC_Application/modehandler.h b/Software/PC_Application/modehandler.h index de4e1d0..e34e662 100644 --- a/Software/PC_Application/modehandler.h +++ b/Software/PC_Application/modehandler.h @@ -21,6 +21,11 @@ public: void closeModes(); int getCurrentIndex(); + Mode* getActiveMode(); + + void activate(Mode * mode); + void deactivate(Mode* mode); + Mode* getMode(int index); std::vector getModes(); @@ -28,8 +33,6 @@ public: int findIndex(Mode *targetMode); Mode* findFirstOfType(Mode::Type t); - void setAveragingMode(Averaging::Mode m); - signals: void StatusBarMessageChanged(const QString &msg); @@ -44,7 +47,9 @@ private: std::vector modes; int currentModeIndex; int createMode(Mode *mode); + Mode *createNew(AppWindow *window, QString name, Mode::Type t); AppWindow *aw; + Mode *activeMode = nullptr; private slots: void setStatusBarMessageChanged(const QString &msg);