Skip to content

Commit

Permalink
datamonitor: plot Y axis autoscaler only when is running
Browse files Browse the repository at this point in the history
Signed-off-by: Ionut Muthi <[email protected]>
  • Loading branch information
IonutMuthi committed May 7, 2024
1 parent a2bb01b commit cd87b68
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ class TimeManager : public QObject

Q_SIGNALS:
void timeout();
void toggleRunning(bool toggled);

private:
static TimeManager *pinstance_;
Expand Down
15 changes: 13 additions & 2 deletions plugins/datamonitorPlugin/src/menus/datamonitorsettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
#include <QDebug>
#include <QLineEdit>
#include <QScrollArea>
#include <QTimer>
#include <datamonitorstylehelper.hpp>
#include <datamonitorutils.hpp>
#include <menucollapsesection.h>
Expand All @@ -16,6 +15,7 @@
#include <mousewheelwidgetguard.h>
#include <plotautoscaler.h>
#include <plotchannel.h>
#include <timemanager.hpp>

using namespace scopy;
using namespace datamonitor;
Expand Down Expand Up @@ -119,6 +119,7 @@ QWidget *DataMonitorSettings::generateYAxisSettings(QWidget *parent)
plotAutoscaler->setTolerance(10);

MenuOnOffSwitch *autoscale = new MenuOnOffSwitch(tr("AUTOSCALE"), yAxisSection, false);
autoscale->onOffswitch()->setChecked(true);

connect(autoscale->onOffswitch(), &QAbstractButton::toggled, this, [=, this](bool toggled) {
plotYAxisController->setEnabled(!toggled);
Expand All @@ -129,7 +130,17 @@ QWidget *DataMonitorSettings::generateYAxisSettings(QWidget *parent)
}
});

autoscale->onOffswitch()->setChecked(true);
auto &&timeTracker = TimeManager::GetInstance();

connect(timeTracker, &TimeManager::toggleRunning, this, [=, this](bool toggled){
if (toggled) {
if (autoscale->onOffswitch()->isChecked()) {
plotAutoscaler->start();
}
} else {
plotAutoscaler->stop();
}
});

connect(plotAutoscaler, &gui::PlotAutoscaler::newMin, m_plot, &MonitorPlot::updateYAxisIntervalMin);
connect(plotAutoscaler, &gui::PlotAutoscaler::newMax, m_plot, &MonitorPlot::updateYAxisIntervalMax);
Expand Down
6 changes: 5 additions & 1 deletion plugins/datamonitorPlugin/src/timemanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@ void TimeManager::setTimerInterval(double interval) { m_timer->setInterval(inter

bool TimeManager::isRunning() const { return m_isRunning; }

void TimeManager::setIsRunning(bool newIsRunning) { m_isRunning = newIsRunning; }
void TimeManager::setIsRunning(bool newIsRunning)
{
m_isRunning = newIsRunning;
Q_EMIT toggleRunning(newIsRunning);
}

QDateTime TimeManager::lastReadValue() const { return m_lastReadValue; }

0 comments on commit cd87b68

Please sign in to comment.