diff --git a/Core/modulemessagesbroker.cpp b/Core/modulemessagesbroker.cpp index baeb46b42ef7505253956d341befbb9ed7d4c3d1..b79efaa287f3e4a82fd839534369dcfd924af552 100644 --- a/Core/modulemessagesbroker.cpp +++ b/Core/modulemessagesbroker.cpp @@ -77,11 +77,10 @@ QList<QString> ModuleMessagesBroker::getSubscriptionsOf(Module *module) void ModuleMessagesBroker::onModuleDeleted(Module *module) { for(auto topic : observers.keys()){ - auto observer = observers[topic]; - if(observer.contains(module)){ - observer.remove(module); + if(observers[topic].contains(module)){ + observers[topic].remove(module); } - if(observer.isEmpty()){ + if(observers[topic].isEmpty()){ observers.remove(topic); } } diff --git a/Modules/CommandPad/commandpadmodule.ui b/Modules/CommandPad/commandpadmodule.ui index f62621cb18facc43c19d1281e68e50c8d4cc2c19..789d9a0e6fff8000c37ed8080eb0c107816a4a2d 100644 --- a/Modules/CommandPad/commandpadmodule.ui +++ b/Modules/CommandPad/commandpadmodule.ui @@ -49,7 +49,7 @@ </font> </property> <property name="text"> - <string>R2A - Ground Station</string> + <string>Ground Station</string> </property> </widget> </item> @@ -495,13 +495,6 @@ <set>Qt::AlignCenter</set> </property> <layout class="QGridLayout" name="gridLayout_4"> - <item row="0" column="1"> - <widget class="QPushButton" name="disarm_button"> - <property name="text"> - <string>DISARM</string> - </property> - </widget> - </item> <item row="0" column="0"> <widget class="QPushButton" name="arm_button"> <property name="text"> @@ -509,14 +502,21 @@ </property> </widget> </item> - <item row="1" column="0"> + <item row="0" column="1"> <widget class="QPushButton" name="forceLaunch_button"> <property name="text"> <string>FORCE LAUNCH</string> </property> </widget> </item> - <item row="1" column="1"> + <item row="0" column="2"> + <widget class="QPushButton" name="disarm_button"> + <property name="text"> + <string>DISARM</string> + </property> + </widget> + </item> + <item row="0" column="3"> <widget class="QPushButton" name="forceInit_button"> <property name="text"> <string>FORCE INIT</string> @@ -534,13 +534,19 @@ <property name="alignment"> <set>Qt::AlignCenter</set> </property> + <property name="checkable"> + <bool>true</bool> + </property> + <property name="checked"> + <bool>false</bool> + </property> <layout class="QGridLayout" name="gridLayout_3"> <item row="1" column="0"> <widget class="QPushButton" name="endMission_button"> <property name="minimumSize"> <size> - <width>50</width> - <height>50</height> + <width>20</width> + <height>40</height> </size> </property> <property name="text"> @@ -552,8 +558,8 @@ <widget class="QPushButton" name="noseconeOpen_button"> <property name="minimumSize"> <size> - <width>50</width> - <height>50</height> + <width>20</width> + <height>40</height> </size> </property> <property name="text"> @@ -565,8 +571,8 @@ <widget class="QPushButton" name="cutDrogue_button"> <property name="minimumSize"> <size> - <width>50</width> - <height>50</height> + <width>20</width> + <height>40</height> </size> </property> <property name="text"> diff --git a/Modules/Graph/graphmodule.cpp b/Modules/Graph/graphmodule.cpp index 6ecf3395e09b7beeba3f56c09f7dd49bf883245f..bb931369ee82ac3905f0457882d172b7b441b39e 100644 --- a/Modules/Graph/graphmodule.cpp +++ b/Modules/Graph/graphmodule.cpp @@ -20,6 +20,9 @@ GraphModule::GraphModule(QWidget *parent) : DefaultModule(parent), ui(new Ui::Gr GraphModule::~GraphModule() { + // QCPGraph are destroyed automatically + + subscriptions.clear(); delete ui; } @@ -153,6 +156,7 @@ void GraphModule::onSubscribeClicked() sPanel->show(); } + void GraphModule::onSubscriptionAdded(const QString &subscription) { QCPGraph *graph = instantiateNewGraph(); @@ -184,6 +188,9 @@ void GraphModule::onMsgReceived(const ModuleMessage &msg) onSubscriptionAdded(msg.originalTopic()); } + if(stopPlot) + return; + if(subscriptions.contains(msg.originalTopic())){ QCPGraph *graph = subscriptions[msg.originalTopic()]; @@ -221,6 +228,28 @@ void GraphModule::setFollowedGraphIndex(bool checked) } } +void GraphModule::onClearClicked() +{ + QMapIterator<QString,QCPGraph*> i(subscriptions); + while (i.hasNext()) { + i.next(); + i.value()->data()->clear(); + } + + replotAll(); +} + +void GraphModule::onStopClicked(bool checked) +{ + stopPlot = checked; + + if(stopPlot) + updaterTimer.stop(); + else{ + updaterTimer.start(updatePeriod); + } +} + QCPGraph *GraphModule::getSelectedGraph() { @@ -258,6 +287,14 @@ void GraphModule::addCustomActionsToMenu() QAction* subscribe = new QAction("Subscribe"); connect(subscribe, &QAction::triggered,this, &GraphModule::onSubscribeClicked); + QAction* clear = new QAction("Clear"); + connect(clear, &QAction::triggered,this, &GraphModule::onClearClicked); + + QAction* stop = new QAction("Stop"); + stop->setCheckable(true); + stop->setChecked(stopPlot); + connect(stop,&QAction::triggered,this,&GraphModule::onStopClicked); + QAction* follow = new QAction("Follow"); follow->setCheckable(true); if(followedGraphIndex >= 0){ @@ -265,7 +302,9 @@ void GraphModule::addCustomActionsToMenu() } connect(follow,&QAction::triggered,this,&GraphModule::setFollowedGraphIndex); - addActionToMenu(subscribe); addActionToMenu(follow); + addActionToMenu(subscribe); + addActionToMenu(clear); + addActionToMenu(stop); } diff --git a/Modules/Graph/graphmodule.h b/Modules/Graph/graphmodule.h index 95baf59d4de93f6c04ad9ec39aca975b24879a15..8d4c272885393c3eed34951d84e0d4f8db456be2 100644 --- a/Modules/Graph/graphmodule.h +++ b/Modules/Graph/graphmodule.h @@ -34,7 +34,8 @@ public slots: void onSubscriptionRemoved(const QString &subscription); void onMsgReceived(const ModuleMessage &msg); void setFollowedGraphIndex(bool checked); - + void onClearClicked(); + void onStopClicked(bool checked); protected: void buildCentralGraphView(); @@ -54,6 +55,7 @@ private: //QSharedPointer<QCPAxisTickerDateTime> dateTicker; QTimer updaterTimer; int updatePeriod = 1000; // [ms] + bool stopPlot = false; }; #endif // GRAPHMODULE_H diff --git a/SkywardHub.pro.user b/SkywardHub.pro.user index c86aea08eedf65a3b1b00c1d594ee24df6ae6b05..0cb2cc5093ac618c613c74b1e86a1ca96abfdfe7 100644 --- a/SkywardHub.pro.user +++ b/SkywardHub.pro.user @@ -1,6 +1,6 @@ <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE QtCreatorProject> -<!-- Written by QtCreator 4.14.2, 2021-07-20T21:19:28. --> +<!-- Written by QtCreator 4.14.2, 2021-07-21T17:14:25. --> <qtcreator> <data> <variable>EnvironmentId</variable>