--- a/src/SimulatorWindow.cpp Thu Mar 14 20:39:34 2019 +0100
+++ b/src/SimulatorWindow.cpp Thu Mar 14 21:37:43 2019 +0100
@@ -50,6 +50,10 @@
std::vector<QString> axisLabels = {"X", "Y", "Z"};
+ timer = new QTimer(centralwidget);
+ connect(timer, &QTimer::timeout, this, &SimulatorWindow::sendMotionEvent);
+ timer->setInterval(20);
+
formLayout->setWidget(f++, QFormLayout::LabelRole, new QLabel("Motion:", centralwidget));
for (QString a : axisLabels) {
QSlider* slider = createSlider(centralwidget);
@@ -74,6 +78,15 @@
connect(centerButton, &QPushButton::clicked, this, &SimulatorWindow::centerAll);
formLayout->setWidget(f++, QFormLayout::FieldRole, centerButton);
+
+ formLayout->setWidget(f++, QFormLayout::LabelRole, new QLabel("Options:", centralwidget));
+ periodicButton = new QCheckBox("Periodic updates", centralwidget);
+ connect(periodicButton, &QCheckBox::clicked, [this](bool enabled) {
+ if (enabled) timer->start();
+ else timer->stop();
+ });
+ formLayout->setWidget(f++, QFormLayout::FieldRole, periodicButton);
+
setCentralWidget(centralwidget);
}
--- a/src/SimulatorWindow.h Thu Mar 14 20:39:34 2019 +0100
+++ b/src/SimulatorWindow.h Thu Mar 14 21:37:43 2019 +0100
@@ -22,6 +22,7 @@
#include <QCheckBox>
#include <QSlider>
#include <QPushButton>
+#include <QTimer>
#include "MotionEvent.h"
#include "ButtonEvent.h"
@@ -40,7 +41,9 @@
std::vector<QSlider*> motions;
std::vector<QSlider*> rotations;
QPushButton* centerButton;
+ QCheckBox* periodicButton;
QSlider* createSlider(QWidget* parent);
+ QTimer* timer;
private slots:
void centerAll();